Skip to content

Commit 8d803bd

Browse files
committed
Merge pull request davidstutz#275 from Tyf0x/master
Select-All performance improvement.
2 parents 47d60e3 + 74e24a5 commit 8d803bd

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

js/bootstrap-multiselect.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -345,25 +345,19 @@
345345
var $checkboxesNotThis = $('input', this.$container).not($target);
346346

347347
if (isSelectAllOption) {
348-
if (this.$select[0][0].value === this.options.selectAllValue) {
349-
350-
var values = [];
351-
var options = $('option[value!="' + this.options.selectAllValue + '"][data-role!="divider"]', this.$select);
352-
353-
for (var i = 0; i < options.length; i++) {
354-
355-
// Check whether this option is actually visible.
356-
if (this.getInputByValue(options[i].value) && this.getInputByValue(options[i].value).is(':visible')) {
357-
values.push(options[i].value);
358-
}
359-
}
348+
var values = [];
349+
// Select the visible checkboxes except the "select-all" and possible divider.
350+
var availableInputs = $('li input[value!="' + this.options.selectAllValue + '"][data-role!="divider"]', this.$ul).filter(':visible');
351+
352+
for (var i = 0, j = availableInputs.length; i < j; i++) {
353+
values.push(availableInputs[i].value);
354+
}
360355

361-
if (checked) {
362-
this.select(values);
363-
}
364-
else {
365-
this.deselect(values);
366-
}
356+
if (checked) {
357+
this.select(values);
358+
}
359+
else {
360+
this.deselect(values);
367361
}
368362
}
369363

0 commit comments

Comments
 (0)