I have a wait function in Prototype with which I can delay the execution of a function around time. Sample:
var doSomting = function(arg 1, arg2, ...){
...
}.wait(500);
The wait - Functions Code in Prototype is:
Function.prototype.wait = function(time){
var fn = this;
var timeout = null;
return function(){
var inst = this;
var args = arguments;
$clear(timeout);
timeout = window.setTimeout( function(){
var ret = fn.apply(inst,args);
}, time);
};
};
I would like to have the same Methode waitSpecial(time)
in jQuery (wait is taken in jQuery, so waitSpecial()
)
I cannot convert the function. It is very helpful for me to convert.
Function.prototype.wait = function(time){
var fn = this;
var timeout = null;
return function(){
var inst = this;
var args = arguments;
clearTimeout(timeout);
timeout = window.setTimeout( function(){
var ret = fn.apply(inst,args);
}, time);
};
};
It works with jQuery fine