【问题标题】:Jquery accordion retain the open pane on postbackJquery 手风琴在回发时保留打开的窗格
【发布时间】:2014-07-02 23:28:56
【问题描述】:

我正在尝试将打开的窗格保留在手风琴中。这就是我的页面中的内容

 <div id="accordion">
    <h3>Applicant Type</h3>
    <div>                          
        some content 
    </div>
    <h3>Application Details</h3>
    <div> 
    </div>
    <h3>Current Residential Address Details</h3>
    <div>
        some content 
    </div>
    <h3>Previous Residential Address Details</h3>
    <div>
        some content 
    </div>
    <h3>Originator Details</h3>
    <div>
        some content 
    </div>  
</div> 
var leftActiveIndex = parseInt($('#<%=LeftAccordionIndex.ClientID %>').val());

 $("#accordion").accordion({
    autoHeight: false,
    event: "mousedown",
    active: leftActiveIndex,
    change: function (event, ui) {
        //var index = $(this).children('h3').index(ui.newHeader);
        var index = $(this).accordion("option", "active");
        $('input[id$=LeftAccordionIndex]').val(index);
    }
});

我从这个链接去这个, keep-the-current-jquery-accordion-pane-open-after-asp-net-postback

但这似乎对我不起作用。

【问题讨论】:

  • 如果你使用 localStorage 来保存哪个部分是活动的呢?
  • 您没有将脚本包装到
  • 变量 leftActiveIndex 的值始终为 0。我是否缺少此手风琴的 ID 属性来获取变量的值?
  • @Wilfredo P,它在 Document.ready 脚本中。我只复制了这段代码 sn-p。

标签: jquery asp.net jquery-ui


【解决方案1】:

简单的解决方案 - 使用 UpdatePanel。

更复杂的解决方案 - 在您的代码隐藏中使用 HttpHandlers 而不是按钮单击事件处理程序,这样就没有回发。

【讨论】:

    猜你喜欢
    • 2011-10-20
    • 1970-01-01
    • 2020-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-19
    相关资源
    最近更新 更多