1.

How Can Events Be Prevented From Stopping To Work After An Ajax Request?

Answer»

There are two ways to handle this ISSUE:

Use of event delegation: The event delegation technique works on principle by exploiting the event bubbling. It uses event bubbling to capture the events on elements which are present anywhere in the domain object model. In jquery the user can make use of the live and die methods for the events delegation which contains a subset of event types.

For example: handling event delegation, handling of CLICKS on any element:

$('#mydiv').click(function(e){ if( $(e.target).is('a') )
fn.call(e.target,e); }); $('#mydiv').load('my.html')

Event rebinding usage: When this method is USED it requires the user to call the BIND method and the added NEW elements.

For example:

$('a').click(fn); $('#mydiv').load('my.html' ,function(){
$('#mydiv a').click(fn); });

There are two ways to handle this issue:

Use of event delegation: The event delegation technique works on principle by exploiting the event bubbling. It uses event bubbling to capture the events on elements which are present anywhere in the domain object model. In jquery the user can make use of the live and die methods for the events delegation which contains a subset of event types.

For example: handling event delegation, handling of clicks on any element:

Event rebinding usage: When this method is used it requires the user to call the bind method and the added new elements.

For example:



Discussion

No Comment Found