Last active
August 29, 2015 13:56
-
-
Save dbellettini/9090354 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var delayedFunction = makeDelayedFunction(function() { | |
//$.ajax... | |
}); | |
$('#text').change(function() { | |
delayedFunction(); | |
}); |
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
mi fai un esempio d'uso? Tnx