0

Im using http://desandro.github.com/imagesloaded/ imagesLoaded plugin which works great for detecting when a div's images have loaded:

$('.background').imagesLoaded(function() {
console.log('background loaded');
});

I need this to also check when a background-image applied via CSS has been loaded as the above plugin doesnt seem to listen for background-images.

Any ideas?

1
  • $('<img>').attr('href', 'urlHere.jpg').imagesLoaded(function(){ console.log('backgroundImage loaded, apply as BG'); }); might work? Commented Dec 2, 2012 at 20:00

2 Answers 2

2

Take a look at waitForImages plugin, it can detect loading of images referenced in the CSS.

https://github.com/alexanderdickson/waitForImages

Sign up to request clarification or add additional context in comments.

2 Comments

thanks @Michael Samteladze, this looks like a good plugin but having a few issues with it. I have 20 divs with background images on. I can set this plugin to check for when each divs images are loaded. but when each call is made to say a div is ready i cannot reference the div, only the image object.
@TomD The this should be a reference to the image. If it's not, please file an issue.
2

This is a known issue in this plugin, but there is a workaround, Please read darcyclarke comment in this page https://github.com/desandro/imagesloaded/issues/29

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.