在 asp.Net 回发后,jquery 手风琴不会重新启动 [英] jquery accordion not re-initiating after an asp.Net postback

查看:27
本文介绍了在 asp.Net 回发后,jquery 手风琴不会重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在启动一个 jquery 手风琴:

I'm firing up a jquery accordion with:

$(document).ready(function(){
   $('#accordion').accordion();
});

问题是这是一个 .asp.NET 应用程序,如果页面触发回发,则会破坏手风琴.如何在回发时重新启动手风琴?

Problem is this is an .asp.NET application and if the page fires a postback is destroys the accordion. How do I re-initiate the accordion upon postback?

抱歉,我不是 asp.NET 专家,也很抱歉我无法提供示例链接,因为它是受密码保护的应用程序.

Sorry I'm not an expert on asp.NET, and also sorry I can't give you a link to the example, this is because it's a password protected application.

谢谢.

推荐答案

在使用 UpdatePanel 函数回发后,您需要重新初始化手风琴:

You need to re-initlaize the accordion after the post back with the UpdatePanel functions as:

<script type="text/javascript"> 
$(document).ready(function(){
    var prm = Sys.WebForms.PageRequestManager.getInstance();    
        prm.add_initializeRequest(InitializeRequest);
        prm.add_endRequest(EndRequest);
   // on page ready first init of your accordion
   $('#accordion').accordion();
});


function InitializeRequest(sender, args) {      
}

function EndRequest(sender, args) {
     // after the UpdatePanel finish the render from ajax call
     //  and the DOM is ready, re-initilize the accordion
     $('#accordion').accordion();
}
</script>

亲属:
Gridview Jquery DatePicker 中的 Asp.Net UpdatePanel
ASP.Net:需要在更新面板加载完成时运行 javascript
如何让客户端脚本在 ASP.NET 回发上执行?(来自更新面板)

这篇关于在 asp.Net 回发后,jquery 手风琴不会重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆