本文介绍了控件的UpdatePanel JQuery的丢失事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮,是UpdatePanel控件中。按钮的Click事件具有通过JQuery的为它定义一个函数。一旦异步回发完成JQuery的事件无法被点击之后按钮时开火。 什么我需要做的纠正此行为,维护JQuery的事件连接到按钮的点击事件一旦被刷新异步?

I have a button that is within an updatepanel control. The button's click event has a function defined for it through JQuery. Once the async postback completes the JQuery event fails to fire when the button is clicked subsequently. What do I need to do to correct this behavior and maintain the JQuery event attachment to the button's click event once it has been refreshed asynchronously?

推荐答案

把你的jQuery事件处理程序下面的函数

put your jquery event handler binding inside the following function

function pageLoad(sender,args) {

    // binding code here, for example
    $('#button').click(function(e) {
        // do something when the click event is raised
    });

}

页面加载终止后每回发,同步或异步执行。 页面加载在ASP.NET AJAX保留函数名称就是为了这个目的。 $(文件)。就绪(),另一方面,只执行一次,当DOM最初是准备/加载。

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.

请参阅此

这篇关于控件的UpdatePanel JQuery的丢失事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 06:26