Friday, April 15, 2011

jQuery jQuery $(document).ready with UpdatePanel problem

Every time an UpdatePanel fires a partial page update, JQuery does not work any more.

Cause:
An UpdatePanel replaces the contents of the update panel on an update.
So Jquery event handlers are gone, because elememnts gone first.

Solution:
Put event handlers from $(document).ready()  to

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function() {
    // re-bind your jquery events here
});


Reference:
http://encosia.com/2009/03/25/document-ready-and-pageload-are-not-the-same/

No comments:

Post a Comment