Created
October 5, 2016 19:29
-
-
Save james2doyle/85c2d634c6c0fb82224ff43de2d791e8 to your computer and use it in GitHub Desktop.
A debounce timeout trigger for typing in an input. The example is in jQuery, but this works with any event/listener.
This file contains hidden or 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
$('#input').on('keyup', function() { | |
// do an ajax save when this input is changed | |
var val = this.value; | |
// clear the timeout so we dont fire in succession | |
clearTimeout(this.delayer); | |
this.delayer = setTimeout(function () { | |
console.log(val); | |
}, 500); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment