diff --git a/index.html b/index.html index 22b11976..c0995bf0 100644 --- a/index.html +++ b/index.html @@ -54,10 +54,6 @@

Bootstrap Multiselect

Bootstrap Multiselect is a JQuery based plugin to provide an intuitive user interface for using select inputs with the multiple attribute present. Instead of a select a bootstrap button will be shown as dropdown menu containing the single options as checkboxes.

- -

- Please have a look at the Contribution Guidelines and the Issue Tracker. -

@@ -66,11 +62,15 @@

Bootstrap Multiselect

event.stopPropagation(); }); - +

The demonstration page for Bootstrap 2.3.x was removed. Nevertheless, this page should be working with Bootstrap 2.3.x as well except for some methods which are marked accordingly.

+

+ Please have a look at the Contribution Guidelines and the Issue Tracker. +

+ @@ -987,6 +987,12 @@

Options

+ + checkboxName + + Per default, this option is set to false and the generated checkboxes (or radio buttons) are not given any name. If not set to false, this option defines the name of all checkboxes (or radio buttons). + + includeSelectAllOption @@ -1459,15 +1465,17 @@

Methods

- - +
+ + +

.multiselect('setOptions', options)

- Used to change configuration after initializing the multiselect. This may be useful in combination with .multiselect('rebuild'). + Used to change configuration after initializing the multiselect. This may be useful in combination with .multiselect('rebuild'). See the Further Examples section for an example.

@@ -2593,6 +2601,21 @@

Frequently Asked Questions

Have a look at the Further Examples section (in addition, issue 360 discussed this).

+ +

+ Using multiple select's in single selection mode with option's sharing values across the different select's. +

+

+ This issue is discussed in detail here: #362. A simple solution is to use different option values for the option checkboxName: +

+
+$('.multiselect').multiselect({
+    checkboxName: _.uniqueId('multiselect_')
+});
+            
+

+ where _.uniqueId('multiselect_') should be replaced with a random generator. Alternatively, a unique value for checkboxName can be used for each multiselect. +

diff --git a/js/bootstrap-multiselect.js b/js/bootstrap-multiselect.js index 14584aab..3e21e407 100644 --- a/js/bootstrap-multiselect.js +++ b/js/bootstrap-multiselect.js @@ -235,7 +235,7 @@ // Maximum height of the dropdown menu. // If maximum height is exceeded a scrollbar will be displayed. maxHeight: false, - checkboxName: 'multiselect', + checkboxName: false, includeSelectAllOption: false, includeSelectAllIfMoreThan: 0, selectAllText: ' Select all', @@ -546,8 +546,14 @@ var $li = $(this.options.templates.li); $('label', $li).addClass(inputType); - $('label', $li).append(''); - + + if (this.options.checkboxName) { + $('label', $li).append(''); + } + else { + $('label', $li).append(''); + } + var selected = $(element).prop('selected') || false; var $checkbox = $('input', $li); $checkbox.val(value); @@ -631,8 +637,14 @@ var $li = $(this.options.templates.li); $('label', $li).addClass("checkbox"); - $('label', $li).append(''); - + + if (this.options.checkboxName) { + $('label', $li).append(''); + } + else { + $('label', $li).append(''); + } + var $checkbox = $('input', $li); $checkbox.val(this.options.selectAllValue); @@ -791,7 +803,7 @@ var $checkbox = this.getInputByValue(value); if($option === undefined || $checkbox === undefined) { - continue; + continue; } if (!this.options.multiple) { @@ -845,7 +857,7 @@ var $checkbox = this.getInputByValue(value); if($option === undefined || $checkbox === undefined) { - continue; + continue; } if (this.options.selectedClass) { @@ -901,7 +913,7 @@ var justVisible = typeof justVisible === 'undefined' ? true : justVisible; if(justVisible) { - var visibleCheckboxes = allCheckboxes.filter(":visible"); + var visibleCheckboxes = $("li input[type='checkbox']:enabled", this.$ul).filter(":visible"); visibleCheckboxes.prop('checked', false); var values = visibleCheckboxes.map(function() { @@ -912,14 +924,17 @@ return $.inArray($(this).val(), values) !== -1; }).prop('selected', false); - $("li:not(.divider):not(.disabled)", this.$ul).filter(":visible").removeClass(this.options.selectedClass); + if (this.options.selectedClass) { + $("li:not(.divider):not(.disabled)", this.$ul).filter(":visible").removeClass(this.options.selectedClass); + } } else { - var allCheckboxes = $("li input[type='checkbox']:enabled", this.$ul); - allCheckboxes.prop('checked', false); - + $("li input[type='checkbox']:enabled", this.$ul).prop('checked', false); $("option:enabled", this.$select).prop('selected', false); - $("li:not(.divider):not(.disabled)", this.$ul).removeClass(this.options.selectedClass); + + if (this.options.selectedClass) { + $("li:not(.divider):not(.disabled)", this.$ul).removeClass(this.options.selectedClass); + } } },