diff options
author | lou <louiscuny@gmail.com> | 2011-08-24 17:56:46 +0200 |
---|---|---|
committer | lou <louiscuny@gmail.com> | 2011-08-24 17:56:46 +0200 |
commit | 8ce280561e09e84f3b4235350238d0d9e22d3f44 (patch) | |
tree | b8da41e63e6402a155c0ec2c2917f36ffc1c2135 /js/jquery.multi-select.js | |
parent | 89770af5b8bc24935faceb697119174858652a79 (diff) | |
download | multi-select-8ce280561e09e84f3b4235350238d0d9e22d3f44.zip multi-select-8ce280561e09e84f3b4235350238d0d9e22d3f44.tar.gz multi-select-8ce280561e09e84f3b4235350238d0d9e22d3f44.tar.bz2 |
fix multiselect when using optgroup
Diffstat (limited to 'js/jquery.multi-select.js')
-rw-r--r-- | js/jquery.multi-select.js | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/js/jquery.multi-select.js b/js/jquery.multi-select.js index 96d19ac..9ab77de 100644 --- a/js/jquery.multi-select.js +++ b/js/jquery.multi-select.js @@ -24,14 +24,14 @@ selectedUl = $('<ul></ul>'); if (multiSelects.settings.emptyArray){ - if (ms.children("option[value='']").length == 0){ + if (ms.find("option[value='']").length == 0){ ms.prepend("<option value='' selected='selected'></option>"); } else { - ms.children("option[value='']").attr('selected', 'selected'); + ms.find("option[value='']").attr('selected', 'selected'); } } ms.data('settings', multiSelects.settings); - ms.children("option:not(option[value=''])").each(function(){ + ms.find("option:not(option[value=''])").each(function(){ var selectableLi = $('<li ms-value="'+$(this).val()+'">'+$(this).text()+'</li>'); if ($(this).attr('title')) @@ -56,7 +56,7 @@ container.append(selectableContainer); container.append(selectedContainer); ms.after(container); - ms.children('option:selected').each(function(){ + ms.find('option:selected').each(function(){ ms.multiSelect('select', $(this).val(), 'init'); }); } @@ -86,8 +86,8 @@ ms.multiSelect('deselect', $(this).attr('ms-value')); }); selectedUl.append(selectedLi); - if (ms.children("option[value='']")){ - ms.children("option[value='']").removeAttr('selected'); + if (ms.find("option[value='']")){ + ms.find("option[value='']").removeAttr('selected'); } if(method != 'init'){ selectedUl.trigger('change'); @@ -114,8 +114,8 @@ selectableLi.show(); selectedLi.remove(); if (ms.data('settings').emptyArray && selectedUl.children('li').length == 0){ - if (ms.children("option[value='']")){ - ms.children("option[value='']").attr('selected', 'selected'); + if (ms.find("option[value='']")){ + ms.find("option[value='']").attr('selected', 'selected'); } } selectedUl.trigger('change'); @@ -126,14 +126,16 @@ } }, 'select_all' : function(){ + console.time('select_all'); var ms = this; - ms.children("option:not(option[value=''])").each(function(){ + ms.find("option:not(option[value=''])").each(function(){ ms.multiSelect('select', $(this).val(), 'select_all'); }); + console.timeEnd('select_all'); }, 'deselect_all' : function(){ var ms = this; - ms.children("option:not(option[value=''])").each(function(){ + ms.find("option:not(option[value=''])").each(function(){ ms.multiSelect('deselect', $(this).val(), 'deselect_all'); }); } |