Article
Comments
Gas Oved
Aug 31 2009
Tiny but very useful plugin. Thank you very much!
xavier
Oct 30 2009
Enjoy :)
// $(this).animate(xxx).delay(2000,function(){}).animate(xxx)
jQuery.fn.delay = function(t, f)
{
return
$(this).animate({d:1}, t, f) ;
}
Evan Byrne
Oct 31 2009
xavier, that's all fine and good for the most simple of implementations, but your solution doesn't give you the ability to cancel a delayed callback.
Nov 28 2009
Just a quick thanks dude, i wasn't looking forward to having to do a delay ;)
Cheers for the plug-in.
George
Dec 08 2009
Beautiful plugin. Works perfectly. Thank you very much.
brett
Jan 19 2010
You're updated script with the cancel command is awesome! Thanks so much :)
Mark
Mar 10 2010
The timer consumes resource as is working till the time event triggers.
It means though we set timer to delay 50000 ms, the system keeps busy on the timer loop. Thanks to multithreading, but it would be better if we could use some alternative.
Evan commented on Xavier, better objective but yet unsatisfying. somebody get more...
Jun 08 2010
THANKS HEAPS ! works like a charm, really was not in the mood to hard code in some settimeout wraps round a horrible ajax form !!!
Jul 16 2010
I don't see how this is significantly different from just doing
var x = setTimeout( function() {
// stuff here
}, timeHere);
and
clearTimeout(x);
Maybe I'm missing something, but it's not more verbose than jQuery.
What I really want is to be able to set a delay in my current thread without locking the browser.
I need to:
myFunction() {
// Do stuff
// delay here
// Carry on here
}
I can't split into multiple functions -- I absolutely must stay within my function. However if I just do a tight loop waiting for a predetermined time, it will lock up any other background threads that I had running.
Really hoping to find a way around this -- any advice much appreciated.
Locker Rushing
Jul 20 2009
Thank you man! Exactly what I needed.
Nice site btw!