Skip to content

Instantly share code, notes, and snippets.

@dbellettini
Last active August 29, 2015 13:56
Show Gist options
  • Save dbellettini/9090354 to your computer and use it in GitHub Desktop.
Save dbellettini/9090354 to your computer and use it in GitHub Desktop.
function makeDelayedFunction(oldFunction, delay) {
var obj = { timeout: false };
return function () {
if (obj.timeout) {
clearTimeout(obj.timeout);
}
obj.timeout = setTimeout(function () {
obj.timeout = false;
oldFunction();
}, delay);
}
}
var delayedFunction = makeDelayedFunction(function() {
//$.ajax...
});
$('#text').change(function() {
delayedFunction();
});
@garak
Copy link

garak commented Feb 19, 2014

mi fai un esempio d'uso? Tnx

@dbellettini
Copy link
Author

fatto, spero sia comprensibile. È minimale ma vado di fretta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment