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.23.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.22.3 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.22.2 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.22.1 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.22.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.21.1 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.21.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.20.6 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.20.5 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.20.4 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.20.3 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.20.2 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.20.1 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.20.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.19.1 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.19.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.18.0 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.17.4 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.17.3 app/assets/javascripts/vendor/jquery.delayedChange.js
effective_datatables-4.17.2 app/assets/javascripts/vendor/jquery.delayedChange.js