Sha256: 51323704c2689a69491f72174734f6c67aeedfb517556d7706982fbc462203a2
Contents?: true
Size: 920 Bytes
Versions: 57
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.on('keyup paste', function() { clearTimeout(timer); timer = setTimeout(function() { var newVal = element.val(); 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 = 'NO_DELAYED_CHANGE_VALUE'; })(jQuery);
Version data entries
57 entries across 57 versions & 1 rubygems