Skip to content

Commit 4ecbffc

Browse files
committed
Fix #136 Hybrid lists not being parsed correctly.
Also fix #176
1 parent 85cf8c3 commit 4ecbffc

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/jquery.multiselect.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,21 @@
156156
var isDisabled = this.disabled;
157157
var isSelected = this.selected;
158158
var labelClasses = [ 'ui-corner-all' ];
159-
var liClasses = (isDisabled ? 'ui-multiselect-disabled ' : ' ') + this.className;
159+
var liClasses = [];
160160
var optLabel;
161161

162+
if(isDisabled) {
163+
liClasses.push('ui-multiselect-disabled');
164+
}
165+
166+
if(this.className) {
167+
liClasses.push(this.className);
168+
}
169+
162170
// is this an optgroup?
163171
if(parent.tagName === 'OPTGROUP') {
164172
optLabel = parent.getAttribute('label');
173+
liClasses.push('ui-multiselect-optgrp-child');
165174

166175
// has this optgroup been added already?
167176
if(!optgroups[optLabel]) {
@@ -186,7 +195,7 @@
186195
labelClasses.push('ui-state-active');
187196
}
188197

189-
html += '<li class="' + liClasses + '">';
198+
html += '<li class="' + liClasses.join(' ') + '">';
190199

191200
// create the label
192201
html += '<label for="' + inputID + '" title="' + title + '" class="' + labelClasses.join(' ') + '">';
@@ -327,7 +336,7 @@
327336
e.preventDefault();
328337

329338
var $this = $(this);
330-
var $inputs = $this.parent().nextUntil('li.ui-multiselect-optgroup-label').find('input:visible:not(:disabled)');
339+
var $inputs = $this.parent().nextUntil(':not(.ui-multiselect-optgrp-child)').find('input:visible:not(:disabled)');
331340
var nodes = $inputs.get();
332341
var label = $this.parent().text();
333342

0 commit comments

Comments
 (0)