malsup / cycle

jQuery Cycle Plugin - Slideshow goodness
http://jquery.malsup.com/cycle/
1.19k stars 307 forks source link

Slides sometimes don't display #102

Open mindbodyheart09 opened 12 years ago

mindbodyheart09 commented 12 years ago

Greetings, if I refresh the page several times, the slide sometimes shows, sometime doesn't. I used FireBug on FireFox to see the code. It seems the code is OK. It happens randomly. Can you shed some light on it?

I'm using jQuery 1.4.3. There are some ways I use the script in a different way. I think I need to point out to help figure out the problem,

1) I use jQuery load to fill the

. From FireBug, it seems the
has been filled

2) I use jQuery.ajax to retrieve a json file from the server to control the slide. ( I'm sure the json file is healthy and retrieved successfully)

3) my thinking is if it could be possible that cycle() function gets executed before jquery.load even finish?

4) The color-marked code is pasted below.

http://dl.dropbox.com/u/30587978/27-02-2012%202-31-08%20PM.png

Any help/suggestions would be greatly appreciated! I hope somebody will spot something I missed. I've been dealing with this problem for a while,

albell commented 12 years ago

First, this isn't a bug in cycle. This would be really more appropriate on stackoverflow.

It seems like you need to:

a) retrieve the JSON b) parse it with jquery and inject the relevant images into the DOM (which takes a non-trivial amount of time) c) call cycle on the relevant containing elements.

At a glance, it looks like you're essentially calling "c" as a callback to "a", without any regard as to whether or not "b" has happened yet. Make sense? You should rethink the sequence of events in your callback function.

I would also update your jquery version while you're at it. 1.4.3 is yesterday's papers. Event delegation is greatly improved in the newer versions.