Created
December 14, 2011 10:17
-
-
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
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( $ ){ | |
$.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