Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
144
rated 0 times [  151] [ 7]  / answers: 1 / hits: 17649  / 15 Years ago, fri, april 17, 2009, 12:00:00

How can I rebind my events (jquery) when I perform a partial page postback?



I am wiring everything up using:



$(document).ready(function(){};


After a partial page postback, my events are not firing.


More From » jquery

 Answers
3

You can either tap into the PageRequestManager endRequestEvent:



Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function(){});


Or if it is control events you're trying to attach, you can use jQuery live events.



Another option is to do the event delegation manually. It is what the live event are doing under the covers. Attach the event handler to the document itself, then conditionally execute your method if the sender of the event was element you expect.



$(document).click(function(e){  
if($(e.target).is(.collapseButton)){
$(this).find(.collapsePanel).slideToggle(500);
}
})

[#99689] Saturday, April 11, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hector

Total Points: 726
Total Questions: 103
Total Answers: 100

Location: Seychelles
Member since Mon, Jun 28, 2021
3 Years ago
hector questions
;