Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- stopping "chained" functions before they end


sssweb - 10:06 pm on Jan 28, 2013 (gmt 0)


Update - for anyone looking for a solution to this, I found the following:

First, the culprit: jQuery .delay() does not respond to .stop(); from the jQuery docs:

The .delay() method is best for delaying between queued jQuery effects. Because it is limited — it doesn't, for example, offer a way to cancel the delay — .delay() is not a replacement for JavaScript's native setTimeout function, which may be more appropriate for certain use cases.

I'm not the only one who's brought this up; the following bug tickets suggest fixes, but I couldn't get them to work (I include them in case better skilled coders can figure them out):

[bugs.jquery.com...] - implies that the 'bug' was fixed as of jquery 1.7, but I upgraded to the latest version and still had the problem

[bugs.jquery.com...] - suggests clearQueue(), but as another poster pointed out here ( [bugs.jquery.com...] ), it doesn't always work

*********

SOLUTIONS: I found two plug-ins that do the trick:

.doTimeout() [benalman.com...] works so far for me

.delayed() [theloveofcode.com...] - this one is chainable and has more functionality; the problem though is that it only works on specific events (i.e. click, onload, etc.); I need it to work directly from a selector: $("id").delay(5000).animate(...);

If anyone can get it to work that way, I'd like to know.


Thread source:: http://www.webmasterworld.com/javascript/4537712.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com