开发者

Attach event to hyperlink click inside update panel?

I am adding a click event (display alert on click) to a html hype开发者_JAVA百科rlink inside an UpdatePanel on document(ready). However, the event never gets fired when I click the hyperlink. Is it because of ASync postback? What is the correct way to do this?

 $(document).ready(function(){
            $('#addExcl').click(function(){
                alert('asassasaas');return false;
            });    
    });


You need to attach the even in every ajax update because the dom struct is change and the events are lost on the part of the update.

var prm = Sys.WebForms.PageRequestManager.getInstance();    
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);

function InitializeRequest(sender, args) {      
}

function EndRequest(sender, args) {
         $('#addExcl').click(function(){
             alert('asassasaas');
             return false;
         }); 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜