Commit 2381debd authored by Piotr Zygmuntowicz's avatar Piotr Zygmuntowicz

Option added for preventing generated inputs (radio or checkboxes) from firing...

Option added for preventing generated inputs (radio or checkboxes) from firing change event (in my case that was unnecessary, change event on select was enough)
parent 46c62ee3
...@@ -343,52 +343,52 @@ ...@@ -343,52 +343,52 @@
$('.multiselect-search', this.$container).val(this.query).on('click', function(event) { $('.multiselect-search', this.$container).val(this.query).on('click', function(event) {
event.stopPropagation(); event.stopPropagation();
}).on('keydown', $.proxy(function(event) { }).on('keydown', $.proxy(function(event) {
// This is useful to catch "keydown" events after the browser has // This is useful to catch "keydown" events after the browser has
// updated the control. // updated the control.
clearTimeout(this.searchTimeout); clearTimeout(this.searchTimeout);
this.searchTimeout = this.asyncFunction($.proxy(function() { this.searchTimeout = this.asyncFunction($.proxy(function() {
if (this.query != event.target.value) { if (this.query != event.target.value) {
this.query = event.target.value; this.query = event.target.value;
$.each($('.multiselect-container li', this.$container), $.proxy(function(index, element) { $.each($('.multiselect-container li', this.$container), $.proxy(function(index, element) {
var value = $('input', element).val();
if (value != this.options.selectAllValue) {
var text = $('label', element).text();
var value = $('input', element).val(); var value = $('input', element).val();
if (value != this.options.selectAllValue) { if (value && text && value != this.options.selectAllValue) {
var text = $('label', element).text(); // by default lets assume that element is not
var value = $('input', element).val(); // interesting for this search
if (value && text && value != this.options.selectAllValue) { var showElement = false;
// by default lets assume that element is not
// interesting for this search var filterCandidate = '';
var showElement = false; if ((this.options.filterBehavior == 'text' || this.options.filterBehavior == 'both')) {
filterCandidate = text;
var filterCandidate = ''; }
if ((this.options.filterBehavior == 'text' || this.options.filterBehavior == 'both')) { if ((this.options.filterBehavior == 'value' || this.options.filterBehavior == 'both')) {
filterCandidate = text; filterCandidate = value;
} }
if ((this.options.filterBehavior == 'value' || this.options.filterBehavior == 'both')) {
filterCandidate = value; if (this.options.enableCaseInsensitiveFiltering && filterCandidate.toLowerCase().indexOf(this.query.toLowerCase()) > -1) {
} showElement = true;
}
if (this.options.enableCaseInsensitiveFiltering && filterCandidate.toLowerCase().indexOf(this.query.toLowerCase()) > -1) { else if (filterCandidate.indexOf(this.query) > -1) {
showElement = true; showElement = true;
} }
else if (filterCandidate.indexOf(this.query) > -1) {
showElement = true; if (showElement) {
} $(element).show();
}
if (showElement) { else {
$(element).show(); $(element).hide();
}
else {
$(element).hide();
}
} }
} }
}, this)); }
} }, this));
}, this), 300, this); }
}, this)); }, this), 300, this);
}, this));
}, },
// Destroy - unbind - the plugin. // Destroy - unbind - the plugin.
...@@ -532,4 +532,4 @@ ...@@ -532,4 +532,4 @@
$("select[data-role=multiselect]").multiselect(); $("select[data-role=multiselect]").multiselect();
}); });
}(window.jQuery); }(window.jQuery);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment