Subscribe to the 'complete' event of a .load() on a specific DOM element?
Posted
by DustMason
on Stack Overflow
See other posts from Stack Overflow
or by DustMason
Published on 2010-04-30T22:09:55Z
Indexed on
2010/04/30
22:17 UTC
Read the original article
Hit count: 121
Hi all,
I already use both .live() and .bind('ajaxComplete') to accomplish certain related tasks, but I have found myself wanting to be able to listen for the 'complete' event of a specific DOM element which will call jQuery's .load() at various times.
In this situation I don't want to listen for ALL complete events globally (unless someone can show me how to get the proper target from the event object returned by 'ajaxComplete'). I would like to be able to do something like this:
$('.selector').load('url.php',{data:data},function(){ ... });
and then somewhere else, attach a handler to listen and execute some other code whenever that ajax call fires and completes:
$('.selector').bind('complete',function(){ ... });
is there any way to do this? or must i always make use of the 'complete' event within the context of the load() method?
© Stack Overflow or respective owner