Sha256: 7a065f9bc3bace9929d9e4157f3e66424027bd15183469f276ad95a25a7b3fdd
Contents?: true
Size: 920 Bytes
Versions: 31
Compression:
Stored size: 920 Bytes
Contents
// http://stackoverflow.com/questions/7373023/throttle-event-calls-in-jquery (function($) { $.fn.delayedChange = function(options) { var timer; var o; if (jQuery.isFunction(options)) { o = { onChange: options }; } else { o = options; } o = $.extend({}, $.fn.delayedChange.defaultOptions, o); return this.each(function() { var element = $(this); element.keyup(function() { clearTimeout(timer); timer = setTimeout(function() { var newVal = element.val(); newVal = $.trim(newVal); if (element.delayedChange.oldVal != newVal) { element.delayedChange.oldVal = newVal; o.onChange.call(this, element); } }, o.delay); }); }); }; $.fn.delayedChange.defaultOptions = { delay: 700, onChange: function(element) { } } $.fn.delayedChange.oldVal = ''; })(jQuery);
Version data entries
31 entries across 31 versions & 1 rubygems