After I make an ajax request by doing something simple like $(element).load(url, callback);
there will be new content on the page that includes images and such.
Is there a way to do something similar to $(window).load(callback)
after the new content has finished loading?
$(window).load();
works nicely when the page is fresh so that you can show a load animation until all content is loaded, but something simple like this seems to be missing for when content is loaded after $(window).load()
has already been triggered.
EDIT 6/6/12 11:55pm: I think everyone is misunderstanding my question. Let me explain a little better:
When you first load a page, you can take advantage of these two events with jQuery: $(document).ready();
and $(window).load();
. The first one fires when the DOM is ready and the second one fires when content is done being loaded (images, etc). After updating the page using jQuery's .load()
method, I am fully aware that I can pass a callback to be executed after the Ajax is completed.
That is not what I want. I want to execute a function after the new content is finished loading, similar to when $(window).load();
fires after a page's initial content has finished loading.
Does that make sense? How can we create an event similar to $(window).load();
for doing stuff after Ajax'ed content is done loading (not just after the HTML has been inserted)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…