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

Version Path
effective_datatables-2.6.21 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.12.2 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.12.1 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.12.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.11.2 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.11.1 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.11.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.10.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.9.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.8.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.7.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.6.20 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.6.19 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.6.18 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.6.17 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.6.16 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.6.15 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.6.14 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.6.13 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-2.6.12 app/assets/javascripts/vendor/jquery.delayedChange.js