Created
June 7, 2013 14:33
-
-
Save raddevon/5729678 to your computer and use it in GitHub Desktop.
Bind form input value change with a 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
// Bind input change with a delay | |
$(document).on('input propertychange', 'textarea', function () { // Change 'textarea' to desired element | |
var detailsElement = $(this), | |
details = $(this).val(); | |
// If it's the propertychange event, make sure it's the value that changed. | |
if (window.event && event.type == 'propertychange' && event.propertyName != 'value') | |
return; | |
// Clear any previously set timer before setting a fresh one | |
window.clearTimeout($(this).data('timeout')); | |
$(this).data('timeout', setTimeout(function () { | |
// Do your thing here | |
}, 5000)); // Change delay as desired. 5000 = 5s | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment