diff --git a/backgrid-filter.js b/backgrid-filter.js index 9686c8a..f1346f2 100644 --- a/backgrid-filter.js +++ b/backgrid-filter.js @@ -70,14 +70,6 @@ */ placeholder: null, - /** - @property [wait=false] The time in milliseconds to wait since the last - change to the search box's value before searching. This value can be - adjusted depending on how often the search box is used and how large the - search index is. For ServerSideFilter this is turned off by default. - */ - wait: false, - /** @param {Object} options @param {Backbone.Collection} options.collection @@ -92,12 +84,6 @@ this.value = options.value || this.value; this.placeholder = options.placeholder || this.placeholder; this.template = options.template || this.template; - this.wait = options.wait || this.wait; - - if (this.wait !== false) { - this.events["keydown input[type=search]"] = "search"; - this._debounceMethods(["search", "clear"]); - } // Persist the query on pagination var collection = this.collection, self = this; @@ -109,20 +95,7 @@ }; } }, - - _debounceMethods: function(methodNames) { - if (_.isString(methodNames)) methodNames = [methodNames]; - - this.undelegateEvents(); - - for (var i = 0, l = methodNames.length; i < l; i++) { - var methodName = methodNames[i]; - var method = this[methodName]; - this[methodName] = _.debounce(method, this.wait); - } - this.delegateEvents(); - }, /** Event handler. Clear the search box and reset the internal search value. */ @@ -303,6 +276,20 @@ }); }, + _debounceMethods: function (methodNames) { + if (_.isString(methodNames)) methodNames = [methodNames]; + + this.undelegateEvents(); + + for (var i = 0, l = methodNames.length; i < l; i++) { + var methodName = methodNames[i]; + var method = this[methodName]; + this[methodName] = _.debounce(method, this.wait); + } + + this.delegateEvents(); + }, + /** Constructs a Javascript regular expression object for #makeMatcher.