views:

29

answers:

1

IE6 has got me again! I can write

slideSuccess.show();

and all will be fine. When I replace that very line with

setTimeout(function() { slideSuccess.show(); }, 1000);

then, after 1 sec, my slide shows up garbled.

(slideSuccess is a jQuery object if that matters.)

Does anyone have any ideas what is going on here?

Thanks.

A: 

Instead of using a setTimeout(), which won't queue the show until 1 second from now, put the timeout in the queue using .delay(), like this:

slideSuccess.delay(1000).show();

Otherwise you're not showing then animating, you're animating and running a .show() during it, whatever animation is executing in the queue...instead you can delay the queue from starting overall, with .delay().

Nick Craver
Thanks. You sure about this? When I do this, the slide shows up instantly (bad) but well formed (good)... And this happens in ALL browsers.
Ollie2893
@Ollie2893 - Perhaps I misunderstood what your intended, what do you *want* to happen? You can do `.show('fast')` for example or `.fadeIn()` (with duration as well) if you want the show in the animation queue as well.
Nick Craver
I do not want any effects - which is also the reason the delay() does not work. Delay() only works in jQuerry effect queues. I simply want the slide to show after a set interval. That's all. The setTimeout code works in all browsers bar IE. What do I need to do to the code so that IE falls in line?
Ollie2893
@Ollie2893 - What other animations are you running? Where are they kicked off? You need to start those after the show, as a callback to the show for example then you can use `setTimeout()` as well. You can also do the hacky-ish `.show(1)` to queue a 1 frame show animation.
Nick Craver
No other animations at all. This is test code. It consists of little more than the one line that I quoted. Obviously there's some code to create the slides but that code works in IE too - just so long as I call it outside the timeout handler. The question specifically relates to the difference in environments between a call outside and inside a timeout handler. There's clearly something that I need to do to help IE. But what?
Ollie2893
@Ollie2893 - Where's the code creating the slides? It has to be doing *something* to mess up the slides, probably a race condition.
Nick Craver
There's no race condition since there's only a single line. I have totally reskinned the plugin I am writing on and the problem's still there. In fact, I am writing this stuff to deal with AJAX submissions where a slide "Saving..." will (hopefully) be superceeded by a slide "Success" when the AJAX calls finishes successfully. I dropped the code into the app and I get the exact same misbehaviour in IE in the AJAX callback as I get in the timeout() callback. It seems that it struggles in every event handler.
Ollie2893
The problem may not be the event handlers but the composition of the slides. Specifically, they comprise some text and an IMG. The slides collapse because the IMG does not show. I have run repeated tests in my rig and every so often, I get a good slide (including the icon). The images are GIF and PNG and should be in cache in the real app - yet in the real app I have never so far managed to get a good image. It's still odd that this only becomes a problem when inside event handling code...
Ollie2893
To clarify, the slides are all pre-loaded. I am not assigning the SRC attribute inside the event handler. I am merely giving .show() on the DIV that comprises the slide.
Ollie2893
Ok - just confirmed that it is definitely an IMG pre-loading problem of some kind. When I open one of these slides before any event handling occurs, then the slides displays correctly AND all the event handlers will subsequently also display the slide correctly. I may have to restate my question...
Ollie2893
The problem may be that I am giving .hide() before the pre-load has completed, somehow aborting that loading which is then subsequently presumed to have occurred. Strange...
Ollie2893