Skip to content

Commit 27e3775

Browse files
Harrismlh758
authored andcommitted
Fix #740 Group label inside an li tag
1 parent 5f55116 commit 27e3775

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/jquery.multiselect.filter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
// show/hide optgroups
182182
$groups.each(function() {
183183
var $this = $(this);
184-
if (!$this.children('li').filter(':visible').length)
184+
if (!$this.find('li').filter(':visible').length)
185185
$this.hide();
186186
});
187187
this.instance._setMenuHeight();

src/jquery.multiselect.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,15 @@
307307
});
308308

309309
// Build the list section for this optgroup, complete w/ option inputs...
310-
var $optionGroup = $( document.createElement('ul') )
311-
.addClass('ui-multiselect-optgroup'
312-
+ (self.options.groupColumns ? ' ui-multiselect-columns' : '')
313-
+ (elem.className && ' ') + elem.className)
314-
.append( $( document.createElement('a') ).text( elem.getAttribute('label') ), options);
315-
316-
list.push($optionGroup);
310+
var $optGroupLabel = $( document.createElement('a') ).text( elem.getAttribute('label') );
311+
var $optGroupItem = $( document.createElement('li') )
312+
.addClass('ui-multiselect-optgroup'
313+
+ (self.options.groupColumns ? ' ui-multiselect-columns' : '')
314+
+ (elem.className && ' ') + elem.className)
315+
var $optionGroup = $( document.createElement('ul') ).append(options)
316+
$optGroupItem.append($optGroupLabel, $optionGroup)
317+
318+
list.push($optGroupItem);
317319
}
318320
else {
319321
list.push(self._makeOption(elem));
@@ -474,7 +476,7 @@
474476
e.preventDefault();
475477

476478
var $this = $(this);
477-
var $inputs = $this.parent().find('input').filter(':visible:not(:disabled)');
479+
var $inputs = $this.next('ul').find('input').filter(':visible:not(:disabled)');
478480
var nodes = $inputs.get();
479481
var label = this.textContent;
480482

0 commit comments

Comments
 (0)