Hi,
There seems to be an issue with the code:
/*
* Create the single select element by cloning the original multiple select.
/
$selectSingle = $(select).clone();
$selectSingle.removeAttr('id').removeAttr('name')
.addClass(options.classPrefix + '-select').insertAfter($(select));
/ Remove all the options inside the original select, and make it hidden */
$(select).empty().hide();
/* Get the list element from options or create a new one */
($list = $(options.list || $("<ul/>").insertAfter($selectSingle)))
.addClass(options.classPrefix + '-list');
/* Add pre-selected options to the list */
$selectSingle.find(':selected').each(function () {
add($(this), null, false);
});
If the HTML does not have a hard-coded "selected='selected'" attribute on the options (for example, the $(select).val() was set programatically), the select values are lost when preforming a $(select).clone(). Therefore, none of the "pre-selected" options are added to the list.
http://bugs.jquery.com/ticket/1294
http://stackoverflow.com/questions/1357410/whats-lost-during-clone-in-jquery
Hi,
There seems to be an issue with the code:
/*
* Create the single select element by cloning the original multiple select.
/
$selectSingle = $(select).clone();
$selectSingle.removeAttr('id').removeAttr('name')
.addClass(options.classPrefix + '-select').insertAfter($(select));
/ Remove all the options inside the original select, and make it hidden */
$(select).empty().hide();
If the HTML does not have a hard-coded "selected='selected'" attribute on the options (for example, the $(select).val() was set programatically), the select values are lost when preforming a $(select).clone(). Therefore, none of the "pre-selected" options are added to the list.
http://bugs.jquery.com/ticket/1294
http://stackoverflow.com/questions/1357410/whats-lost-during-clone-in-jquery