jQuery: Dynamic image handling (waiting for load)

Posted by dclowd9901 on Stack Overflow See other posts from Stack Overflow or by dclowd9901
Published on 2010-03-30T15:13:40Z Indexed on 2010/03/30 15:33 UTC
Read the original article Hit count: 755

Filed under:
|
|
|

I'm trying to write a plugin that has a built in function to wait until all images that are on the page to be loaded before it executes itself. $(window).load() only works if it's the initial load of the page, but if someone wants to pull down some HTML through AJAX that contains images, it doesn't work.

Is there any good way of doing this AND implementing it so that it can be self-contained in the plug-in? I've tried looping over $('img').complete, and I know that doesn't work (the images never load, and the browser crashes under a "script takes too long to complete" bug). For an example of what I'm trying to do, visit the page I'm looking to house the plugin at:

http://www.simplesli.de

If you go to the "more uses" section (click it on the nav bar), you'll see that the image slideshow won't load properly. I know the current code doesn't work, but it's just holding place until I figure something out.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about images