I need to know if there is any event that fires when an element get completed rendering. I have a div say with id A. Now I am creating and rendering that div with ajax and need to access elements inside div. How can I do it. Tried with $("#A").init(). It is not working.
+2
A:
If you are updating your div with an ajax-call, a callback function can be added to the parameters. This callback function will be run once the ajax-call completes:
$("#A").load(url, parameters, function () {
// access elements inside div here
});
Magnar
2009-03-06 13:55:51
I wil l check that on Monday. Thanks a lot.
Tanmoy
2009-03-06 16:05:30
A:
http://docs.jquery.com/Ajax/load#urldatacallback
load( url, data, callback )
why can't u start working with the div in the callback?
Thomas Stock
2009-03-06 13:56:21
A:
The obvious way is to put your manipulation in the callback of the load/ajax/post/etc AJAX call. If you can't do that (for whatever reason), perhaps this the ajaxComplete event is what you're after:
$("#msg").ajaxComplete(function(request, settings){
$(this).append("<li>Request Complete.</li>");
});
Of course you have to detect that it's the right AJAX call that's completed but maybe this helps.
cletus
2009-03-06 14:10:39