Plugins

The plugins site is currently in development.

We've been looking to provide a higher-quality, spam-free experience at the plugins site for some time, and a major error on our part forced us to shut down the current site before we could put the new one in place. We are developing a new site, and you can follow along with its development on GitHub. For more information about this transition, including steps you can take as a plugin author to prepare, please read our post about what's going on.

'selected' attribute not preserved in IE7.


Project:ComboSelect
Version:1.0.2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

When applying this plugin to a select box in IE7, previously selected items are 'lost' upon transformation (they do not show up in the resulting right side select element).

This can be reproduced on the plugin demonstration page:
http://devblog.jasonhuck.com/assets/comboselect_plugin/
(Works fine in Firefox/Safari, just not in IE)

This appears to be caused by a bug in the jquery clone() function, as illustrated here:
http://fligtar.com/testcases/jquery-clone.html

As a proposed workaround, I have replaced these lines in jquery.comboselect.js:

// copy of the options from the original element
// var opts = $(this).children().clone();
var opts = $(this).find('option').clone();

// add an ID to each option for the sorting plugin
opts.each(function(){
$(this).attr('id', $(this).attr('value'));
});

with this:

// copy of the options from the original element
var opts = '';
$(this).find('option').each(function(){
var selected = '';
if ($(this).attr('selected')) selected = ' selected';
opts += "<option id='" + $(this).attr('value') + "' value='" + $(this).attr('value') + "'" + selected + ">"; opts += $(this).text();
opts += '</option>';
});

This solution works across the three browsers previously mentioned.
Hope this helps somebody.

Thanks for a great plugin!