Ticket #1294 (closed bug: wontfix)
selectedIndex lost after clone() in Internet Explorer
| Reported by: | jesse | Owned by: | brandon |
|---|---|---|---|
| Priority: | major | Milestone: | 1.1.4 |
| Component: | core | Version: | 1.1.3 |
| Keywords: | Cc: | ||
| Needs: | Review |
Description
It seems that after a jQuery clone(), the value of select boxes are lost in IE (but not Firefox). Try this out:
<div>
<select>
<option value="0">one</option> <option value="1" selected='selected'>two</option>
</select>
</div>
$(function(){
$('div').clone(true).appendTo('body');
});
The first option will be selected in the cloned select.
Doing something like this fixes the problem (as long as there is only one select box), though I suspect there needs to be a better fix in jQuery explicitly:
$(function(){
var old = $('div'); var clone = old.clone(true); var select_val = $('select', old).val(); $('select', clone).val(select_val); clone.appendTo('body');
});
Change History
Note: See
TracTickets for help on using
tickets.
