Bug Tracker

Modify

Ticket #2941 (closed bug: wontfix)

Opened 5 years ago

Last modified 15 months ago

<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:
Blocking: Blocked by:

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

comment:1 Changed 5 years ago by flesler

  • need changed from Review to Patch
  • Owner set to flesler
  • Status changed from new to assigned

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 4 years ago by dmethvin

  • Keywords clone added

comment:3 Changed 4 years ago by dmethvin

  • Keywords select option added; testcase removed

See also #4193.

comment:4 Changed 4 years ago by brandon

  • Status changed from assigned to closed
  • Resolution set to wontfix

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 3 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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.