summaryrefslogtreecommitdiffstats
path: root/js/jquery.multi-select.js
diff options
context:
space:
mode:
authorlou <louiscuny@gmail.com>2011-09-16 13:44:14 +0200
committerlou <louiscuny@gmail.com>2011-09-16 13:44:14 +0200
commit3227ad2ad329d87d699a994475e6888af561f50c (patch)
treed925a3ec1ed324527bc81e008f3d92b7b1da27b3 /js/jquery.multi-select.js
parent66ed974c79ac5d66504dabd7276c007b1ba4de8f (diff)
parente639f90c35b9a53f025e6a2bda8b079729eb42c3 (diff)
downloadmulti-select-3227ad2ad329d87d699a994475e6888af561f50c.zip
multi-select-3227ad2ad329d87d699a994475e6888af561f50c.tar.gz
multi-select-3227ad2ad329d87d699a994475e6888af561f50c.tar.bz2
Merge branch 'master' into gh-pages
Diffstat (limited to 'js/jquery.multi-select.js')
-rw-r--r--js/jquery.multi-select.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/js/jquery.multi-select.js b/js/jquery.multi-select.js
index c5c9497..9fae41d 100644
--- a/js/jquery.multi-select.js
+++ b/js/jquery.multi-select.js
@@ -32,13 +32,17 @@
}
ms.data('settings', multiSelects.settings);
- var currentOptgroup = null;
+ var optgroupLabel = null,
+ optgroupId = null,
+ optgroupCpt = 0;
ms.find('optgroup,option').each(function(){
if ($(this).is('optgroup')){
- currentOptgroup = $(this).attr('label');
- selectableUl.append($('<li class="ms-optgroup-container" id="ms-optgroup-'+
- $(this).attr('label')+'"><ul class="ms-optgroup"><li class="ms-optgroup-label">'+
- $(this).attr('label')+'</li></ul></li>'));
+ optgroupLabel = $(this).attr('label');
+ optgroupId = 'ms-'+ms.attr('id')+'-optgroup-'+optgroupCpt;
+ selectableUl.append($('<li class="ms-optgroup-container" id="'+
+ optgroupId+'"><ul class="ms-optgroup"><li class="ms-optgroup-label">'+
+ optgroupLabel+'</li></ul></li>'));
+ optgroupCpt++;
}
if ($(this).is("option:not(option[value=''])")){
var selectableLi = $('<li class="ms-elem-selectable" ms-value="'+$(this).val()+'">'+$(this).text()+'</li>');
@@ -52,7 +56,7 @@
selectableLi.click(function(){
ms.multiSelect('select', $(this).attr('ms-value'));
});
- var container = currentOptgroup ? selectableUl.children('#ms-optgroup-'+currentOptgroup).find('ul').first() : selectableUl;
+ var container = optgroupId ? selectableUl.children('#'+optgroupId).find('ul').first() : selectableUl;
container.append(selectableLi);
}
});