Commit 26e4348e authored by David Stutz's avatar David Stutz

Merge pull request #119 from doogi/master

Preventing generated inputs from firing change input.
parents d0f43f45 2381debd
# Project files. # Project files.
*.project *.project
\ No newline at end of file .idea/
\ No newline at end of file
...@@ -120,7 +120,8 @@ ...@@ -120,7 +120,8 @@
enableCaseInsensitiveFiltering : false, enableCaseInsensitiveFiltering : false,
filterPlaceholder : 'Search', filterPlaceholder : 'Search',
// possible options: 'text', 'value', 'both' // possible options: 'text', 'value', 'both'
filterBehavior : 'text' filterBehavior : 'text',
preventInputChangeEvent: false
}, },
constructor : Multiselect, constructor : Multiselect,
...@@ -270,6 +271,10 @@ ...@@ -270,6 +271,10 @@
this.options.onChange($option, checked); this.options.onChange($option, checked);
this.$select.change(); this.$select.change();
if(this.options.preventInputChangeEvent) {
return false;
}
}, this)); }, this));
$('.multiselect-container li a', this.$container).on('touchstart click', function(event) { $('.multiselect-container li a', this.$container).on('touchstart click', function(event) {
...@@ -356,7 +361,7 @@ ...@@ -356,7 +361,7 @@
// by default lets assume that element is not // by default lets assume that element is not
// interesting for this search // interesting for this search
var showElement = false; var showElement = false;
var filterCandidate = ''; var filterCandidate = '';
if ((this.options.filterBehavior == 'text' || this.options.filterBehavior == 'both')) { if ((this.options.filterBehavior == 'text' || this.options.filterBehavior == 'both')) {
filterCandidate = text; filterCandidate = text;
...@@ -364,14 +369,14 @@ ...@@ -364,14 +369,14 @@
if ((this.options.filterBehavior == 'value' || this.options.filterBehavior == 'both')) { if ((this.options.filterBehavior == 'value' || this.options.filterBehavior == 'both')) {
filterCandidate = value; filterCandidate = value;
} }
if (this.options.enableCaseInsensitiveFiltering && filterCandidate.toLowerCase().indexOf(this.query.toLowerCase()) > -1) { if (this.options.enableCaseInsensitiveFiltering && filterCandidate.toLowerCase().indexOf(this.query.toLowerCase()) > -1) {
showElement = true; showElement = true;
} }
else if (filterCandidate.indexOf(this.query) > -1) { else if (filterCandidate.indexOf(this.query) > -1) {
showElement = true; showElement = true;
} }
if (showElement) { if (showElement) {
$(element).show(); $(element).show();
} }
...@@ -471,7 +476,7 @@ ...@@ -471,7 +476,7 @@
$('.multiselect-container', this.$container).html(''); $('.multiselect-container', this.$container).html('');
this.buildDropdown(this.$select, this.options); this.buildDropdown(this.$select, this.options);
this.updateButtonText(); this.updateButtonText();
// Enable filtering. // Enable filtering.
if (this.options.enableFiltering || this.options.enableCaseInsensitiveFiltering) { if (this.options.enableFiltering || this.options.enableCaseInsensitiveFiltering) {
this.buildFilter(); this.buildFilter();
......
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