diff options
author | lou <louiscuny@gmail.com> | 2011-08-25 16:43:05 +0200 |
---|---|---|
committer | lou <louiscuny@gmail.com> | 2011-08-25 16:43:05 +0200 |
commit | 8989b4aefa56dd40bf5ce401c4f295a41cd2513b (patch) | |
tree | 2e1c81129f537fdec8f3af2967c1fb94691d7933 /js/jquery.multi-select.js | |
parent | 95566fd9706952888fbe37028c919f0cb5251919 (diff) | |
download | multi-select-8989b4aefa56dd40bf5ce401c4f295a41cd2513b.zip multi-select-8989b4aefa56dd40bf5ce401c4f295a41cd2513b.tar.gz multi-select-8989b4aefa56dd40bf5ce401c4f295a41cd2513b.tar.bz2 |
remove optgroup label when no more selectable option in it
Diffstat (limited to 'js/jquery.multi-select.js')
-rw-r--r-- | js/jquery.multi-select.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/js/jquery.multi-select.js b/js/jquery.multi-select.js index 7ea713e..98f0770 100644 --- a/js/jquery.multi-select.js +++ b/js/jquery.multi-select.js @@ -88,6 +88,10 @@ (method != 'init' && !selectedOption.attr('selected'))) if (haveToSelect ){ + var parentOptgroup = selectableLi.parent('.ms-optgroup'); + if (parentOptgroup.length > 0) + if (parentOptgroup.children('.ms-elem-selectable:not(:hidden)').length == 1) + parentOptgroup.children('.ms-optgroup-label').hide(); selectableLi.hide(); selectedOption.attr('selected', 'selected'); if(titleAttr){ @@ -121,6 +125,9 @@ selectableLi = selectableUl.children('li[ms-value="'+value+'"]'), selectedLi = selectedUl.children('li[ms-value="'+value+'"]'); + var parentOptgroup = selectableLi.parent('.ms-optgroup'); + if (parentOptgroup.length > 0) + parentOptgroup.children('.ms-optgroup-label').show(); selectedOption.removeAttr('selected'); selectableLi.show(); selectedLi.remove(); |