Created
October 9, 2013 14:54
-
-
Save lokimeyburg/6902599 to your computer and use it in GitHub Desktop.
typewatch.js "call a function after a user has stopped typing."
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
// a simple function to execute a callback, | |
// after the user has stopped typing for a specified amount of time | |
var typewatch = (function(){ | |
var timer = 0; | |
return function(callback, ms){ | |
clearTimeout (timer); | |
timer = setTimeout(callback, ms); | |
}; | |
})(); | |
// call a function after the user has stopped typing | |
$('.my-input').keyup(function () { | |
var self = this; | |
typewatch(function () { | |
//... | |
// CallYourFunctionHere(); | |
// | |
}, 500); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment