Skip to content

Instantly share code, notes, and snippets.

@jorgemanrubia
Created December 14, 2011 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgemanrubia/1476014 to your computer and use it in GitHub Desktop.
Save jorgemanrubia/1476014 to your computer and use it in GitHub Desktop.
Bind a keyup event with a delay, as seen here: http://stackoverflow.com/questions/1909441/jquery-keyup-delay
(function( $ ){
$.fn.delayedKeyup = function(period, handler) {
var delayedHandler = (function() {
var timer = 0;
return function(callback, miliSeconds) {
clearTimeout(timer);
timer = setTimeout(callback, miliSeconds);
}
})();
this.bind('keyup', function(event) {
delayedHandler(handler(event), 300);
});
};
})( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment