I'm trying to use Malsup's jQuery Cycle plugin with jCarousel to allow thumbnails in my pagination to scroll horizontally and it's working fine. The problem is that sometimes the jcarousel plugin doesn't initialize because I believe the pagination is not ready yet. My code looks like this:
$('#slideshow').cycle({
timeout : 0,
speed : 1000,
pager : '#image-carousel ul',
pagerAnchorBuilder: function(idx, slide) {
return '<li><a href="#"><img src="' + slide.src + '" width="107" height="80" /></a></li>';
}
});
$('#image-carousel').jcarousel();
Sometimes when the page loads the jcarousel doesn't work, I used setTimeout to delay its initialization about 2 seconds and it worked every time so I assume it must be because sometimes the pager is not ready yet. I can live with the setTimeout solution for now but I think there must be a better way to handle this.