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

Version Path
effective_datatables-4.17.1 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.17.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.16.2 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.16.1 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.16.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.15.2 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.15.1 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.15.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.14.2 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.14.1 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.14.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.13.5 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.13.4 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.13.3 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.13.2 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.13.1 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.13.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.12.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.11.2 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.11.1 app/assets/javascripts/vendor/jquery.delayedChange.js