Monday 2 July 2012

JQuery.Cycle messes up on DOM ready

I had a bug recently when using JQuery.Cycle for a slideshow with large images.

The cycle method fails on page load when the images aren't cached.

This was because I was using:
$("document").ready(function() {
    // code here
});

Instead of that, if you use:
$(window).load(function() {
    // code here
});

Your content will load prior to the cycle method being executed.

See this Stack Overflow article for the full explanation:
JQuery cycle fails on page refresh

No comments: