如何在更新面板回发后执行JavaScript回调? [英] How to have a javascript callback executed after an update panel postback?

查看:242
本文介绍了如何在更新面板回发后执行JavaScript回调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要在页面之后注册插件事件。

我使用jQuery提示插件来显示用户悬停页面某些元素时的帮助提示。使用css选择器加载。



问题是我使用的是ASP.NET更新面板,第一次回发后,提示停止工作,因为更新面板替换



我需要一种方法在更新面板刷新其内容后执行JavaScript回调,以便重新绑定javascript事件

解决方案



有什么办法吗? div>

而不是将你的jQuery代码放在 $(document).ready()里面

 函数pageLoad(sender,args){
...
}

每次回发,同步或异步后执行

pageLoad pageLoad 是ASP.NET AJAX中为此目的保留的函数名称。 $(document).ready()另一方面,只有在DOM初始准备/加载时才执行一次。



请参阅此 ASP.NET AJAX客户端生命周期事件概述< a>


I'm using a jQuery tip plugin to show help tips when the user hovers certain elements of the page.

I need to register the plugin events after the page is loaded using css selectors.

The problem is I'm using an ASP.NET Update Panel and after the first postback, the tips stop working because the update panel replaces the page content but doesn't rebind the javascript events.

I need a way to execute a javascript callback after the Update Panel refreshes its content, so I can rebind the javascript events to have the tips working again.

Is there any way to do this?

解决方案

Instead of putting your jQuery code inside of $(document).ready(), put it inside

function pageLoad(sender, args) { 
    ... 
}

pageLoad is executed after every postback, synchronous or asynchronous. pageLoad is a reserved function name in ASP.NET AJAX that is for this purpose. $(document).ready() on the other hand, is executed only once, when the DOM is initially ready/loaded.

See this Overview of ASP.NET AJAX client lifecycle events

这篇关于如何在更新面板回发后执行JavaScript回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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