Skip to content

Commit de8b682

Browse files
committed
Fix filter autoReset option
Don't bind filter events to the whole document. Use the element reference instead.
1 parent cc57d2e commit de8b682

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/jquery.multiselect.filter.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@
8787
input: $.proxy(debounce(this._handler, opts.debounceMS), this),
8888
search: $.proxy(this._handler, this)
8989
});
90+
// automatically reset the widget on close?
91+
if(this.options.autoReset) {
92+
elem.bind('multiselectclose', $.proxy(this._reset, this));
93+
}
94+
// rebuild cache when multiselect is updated
95+
elem.bind('multiselectrefresh', $.proxy(function() {
96+
this.updateCache();
97+
this._handler();
98+
}, this));
9099
this.wrapper = $("<div/>").addClass("ui-multiselect-filter").text(opts.label).append(this.input).prependTo(this.header);
91100

92101
// reference to the actual inputs
@@ -129,17 +138,6 @@
129138
this.element.trigger('change');
130139
}
131140
};
132-
133-
// rebuild cache when multiselect is updated
134-
var doc = $(document).bind('multiselectrefresh.'+ this.instance._namespaceID, $.proxy(function() {
135-
this.updateCache();
136-
this._handler();
137-
}, this));
138-
139-
// automatically reset the widget on close?
140-
if(this.options.autoReset) {
141-
doc.bind('multiselectclose.'+ this.instance._namespaceID, $.proxy(this._reset, this));
142-
}
143141
},
144142

145143
// thx for the logic here ben alman
@@ -178,7 +176,7 @@
178176
},
179177

180178
_reset: function() {
181-
this.input.val('').trigger('keyup');
179+
this.input.val('').trigger('input', '');
182180
},
183181

184182
updateCache: function() {

0 commit comments

Comments
 (0)