I want widget.Rotator.rotate()
to be delayed 5 seconds between calls... how do I do this in jQuery... it seems like jQuery's delay()
wouldn't work for this...
You can use plain javascript, this will call your_func once, after 5 seconds:
setTimeout(function() { your_func(); }, 5000);
If your function has no parameters and no explicit receiver you can call directly setTimeout(func, 5000)
There is also a plugin I've used once. It has oneTime
and everyTime
methods.
function
- this will do fine: setTimeout(your_func, 5000);
Oded 2011-01-19 17:36
Rotator.rotate()
does not need the receiver to be set to Rotator
? If you perfom what you suggest, this
will be the window - Phrogz 2011-01-19 17:39
var rotator = function(){
widget.Rotator.rotate();
setTimeout(rotator,5000);
};
rotator();
Or:
setInterval(
function(){ widget.Rotator.rotate() },
5000
);
Or:
setInterval(
widget.Rotator.rotate.bind(widget.Rotator),
5000
);