Bug Tracker

Opened 12 years ago

Closed 11 years ago

Last modified 8 years ago

#2941 closed bug (wontfix)

<select> value and selected option not preserved on clone

Reported by: fligtar Owned by: flesler
Priority: major Milestone: 1.3
Component: core Version: 1.2.5
Keywords: clone select option Cc:
Blocked by: Blocking:

Description

See test case here: http://fligtar.com/testcases/jquery-clone.html

When cloning a table row with a select box and a checkbox, the checkbox's value will be preserved, but the select box's value will not.

I was able to reproduce this in Firefox 3 and Safari.

Change History (5)

comment:1 Changed 12 years ago by flesler

need: ReviewPatch
Owner: set to flesler
Status: newassigned

I think this is expected, the browser respects the selected and checked attributes. (Both are resetted on IE).

Maybe copying the value (or selectedIndex) attribute will be enough. Will check this when I get some time. Thanks for the straight test case, much appreciated.

comment:2 Changed 11 years ago by dmethvin

Keywords: clone added

comment:3 Changed 11 years ago by dmethvin

Keywords: select option added; testcase removed

See also #4193.

comment:4 Changed 11 years ago by brandon

Resolution: wontfix
Status: assignedclosed

This was at one time in core but was removed due to the large performance overhead for such an edge case. I'm not convinced that the values should be cloned with the form elements. To really make it work cross browser you'd have to change the name attributes and ids as well. I remember having issues with radio buttons in Opera where even though it was in a different form only one could be checked. Either the original or the clone.

See also #3716

comment:15 Changed 10 years ago by GayQuery

First, welcome to Spamalot!

Someone delete the pseudo-medicine trash from harmony and maddie please.

Secondly, if you're a genius like me, and performance isn't an issue in a specific case then you can do something like this [excerpt]:

var erg=jQuery("td.add_row",row.parent().parent()); var elf=jQuery("<tr/>");

jQuery.each (

erg, function(i,item) {

var flippingheck=jQuery(item).clone().appendTo(elf); var bloodyhell=jQuery("select",jQuery(item)); var buggerme=jQuery("select",flippingheck);

jQuery.each (

bloodyhell, function(i,spy) {

jQuery(buggerme[i]).attr("selectedIndex",jQuery(spy).attr("selectedIndex"));

}

);

}

);

Other stuff after here

Note: See TracTickets for help on using tickets.