页面重新加载时,打开特定的手风琴面板
我从手风琴面板发布一些数据,然后重新加载页面。我希望重新加载当前面板时打开并聚焦在屏幕上,而不是重新打开第一个面板并将我移回屏幕顶部。我知道我想打开哪个面板,所以我不需要代码来弄清楚面板,只需要知道如何显示它。
$.post('<%= ResolveUrl("~/Contract/AddContractLocation") %>', $(form).serialize(), function (data) {
if (data.Result == "success") {
... yada yada...
window.location.reload();
}
编辑添加:
这是我初始化手风琴的方式:
$("#acc").accordion({
autoHeight: false,
navigation: true
});
这是基本结构:
<fieldset>
<legend>Contract</legend>
<div id="acc">
<h3><a href="#contractinfo">Contract Info</a></h3>
<div>
stuff
</div>
<h3><a href="#locationandrs">Locations and Ratesheets</a></h3>
<div>
stuff
</div>
<h3><a href="#auditibleterms">Auditable Terms</a></h3>
<div>
stuff
</div>
<h3><a href="#contractdocs">Contract Docs</a></h3>
<div>
stuff
</div>
</div>
</fieldset>
From an accordion panel, I post some data and then reload the page. I'd like on the reload for the current panel to be open and focused on the screen rather than re-opening the first panel and moving me back to the top of the screen. I know which panel I want open, so I don't need code to figure out the panel, just how to display it.
$.post('<%= ResolveUrl("~/Contract/AddContractLocation") %>', $(form).serialize(), function (data) {
if (data.Result == "success") {
... yada yada...
window.location.reload();
}
Edit to Add:
This is how I initialize the accordion:
$("#acc").accordion({
autoHeight: false,
navigation: true
});
This is the basic structure:
<fieldset>
<legend>Contract</legend>
<div id="acc">
<h3><a href="#contractinfo">Contract Info</a></h3>
<div>
stuff
</div>
<h3><a href="#locationandrs">Locations and Ratesheets</a></h3>
<div>
stuff
</div>
<h3><a href="#auditibleterms">Auditable Terms</a></h3>
<div>
stuff
</div>
<h3><a href="#contractdocs">Contract Docs</a></h3>
<div>
stuff
</div>
</div>
</fieldset>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
大约一年来第一次回到这段代码,当我在做其他事情时能够解决这个问题。
First time back in this code in about a year, and while I was working on something else was able to figure this out.
您可以将返回值的 active 选项设置为 true 吗?您需要从链接中单击“选项”,但这是文档:
Can you set the active option to true on the returned value? You need to click on 'options' from the link but here's the docs:
提交表单时发送隐藏参数,识别打开的面板。您获取此参数并在输出 HTML 代码期间使用它为适当的面板分配特殊 id。然后在 js 脚本中初始化 Accordion:
仅此而已!
On submitting form send hidden parameter, identifying open panel. You get this parameter and using it assign special id to appropriate panel during outputting HTML code. Then init accordion in js-script:
That's all!