diff options
-rw-r--r-- | demos.html | 2 | ||||
-rw-r--r-- | js/jquery.multi-select.js | 7 |
2 files changed, 8 insertions, 1 deletions
@@ -64,7 +64,7 @@ </div> <div class='optgroup' style='display:none'> <form> - <select multiple='multiple' class='multiselect'> + <select multiple='multiple' class='multiselect' id='optgroup'> <optgroup label="europe"> <option value='fr'>France</option> <option value='ar'>Argentina</option> 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(); |