summaryrefslogtreecommitdiffstats
path: root/js/jquery.multi-select.js
diff options
context:
space:
mode:
authorlou <louiscuny@gmail.com>2012-11-27 12:08:00 +0100
committerlou <louiscuny@gmail.com>2012-11-27 12:08:00 +0100
commit0418d68ed50fec00be7603abfdd7a808722c58f1 (patch)
treeb048cecd2dbcd25f9b3faa3229b87c828f3de4ab /js/jquery.multi-select.js
parentb4108e0ab07b343b2c8bdd87fdb9a65798431940 (diff)
downloadmulti-select-0418d68ed50fec00be7603abfdd7a808722c58f1.zip
multi-select-0418d68ed50fec00be7603abfdd7a808722c58f1.tar.gz
multi-select-0418d68ed50fec00be7603abfdd7a808722c58f1.tar.bz2
fix optgroup
Diffstat (limited to 'js/jquery.multi-select.js')
-rw-r--r--js/jquery.multi-select.js27
1 files changed, 16 insertions, 11 deletions
diff --git a/js/jquery.multi-select.js b/js/jquery.multi-select.js
index 7ceff02..de7d301 100644
--- a/js/jquery.multi-select.js
+++ b/js/jquery.multi-select.js
@@ -42,13 +42,7 @@
var optgroupLabel = null,
optgroupId = null,
optgroupCpt = 0,
- scroll = 0,
- optgroupContainer =
- $('<li class="ms-optgroup-container" id="'+optgroupId+'">\
- <ul class="ms-optgroup">\
- <li class="ms-optgroup-label">'+optgroupLabel+'</li>\
- </ul>\
- </li>');
+ scroll = 0;
ms.find('optgroup, option').each(function(){
@@ -56,8 +50,18 @@
optgroupLabel = $(this).attr('label');
optgroupId = 'ms-'+ms.attr('id')+'-optgroup-'+optgroupCpt;
- selectableUl.append(optgroupContainer);
- selectionUl.append(optgroupContainer.clone());
+ selectableUl.append(
+ '<li class="ms-optgroup-container" id="'+optgroupId+'-selectable">\
+ <ul class="ms-optgroup">\
+ <li class="ms-optgroup-label">'+optgroupLabel+'</li>\
+ </ul>\
+ </li>');
+ selectionUl.append(
+ '<li class="ms-optgroup-container" id="'+optgroupId+'-selection">\
+ <ul class="ms-optgroup">\
+ <li class="ms-optgroup-label">'+optgroupLabel+'</li>\
+ </ul>\
+ </li>');
optgroupCpt++;
} else {
var klass = $(this).attr('class') ? $(this).attr('class') : '',
@@ -76,8 +80,8 @@
}
if (optgroupId){
- selectableUl.children('#'+optgroupId).find('ul').first().append(selectableLi);
- selectionUl.children('#'+optgroupId).find('ul').first().append(selectionUl);
+ selectableUl.children('#'+optgroupId+'-selectable').find('ul').first().append(selectableLi);
+ selectionUl.children('#'+optgroupId+'-selection').find('ul').first().append(selectedLi);
} else {
selectableUl.append(selectableLi);
selectionUl.append(selectedLi);
@@ -97,6 +101,7 @@
container.append(selectableContainer);
container.append(selectionContainer);
+
ms.after(container);
ms.find('option:selected').each(function(){