File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -556,6 +556,20 @@ function uniqueId() {
556
556
}
557
557
558
558
function cloneContents ( container ) {
559
+ // Preserve textarea values
560
+ var textarea = findAll ( container , "textarea" )
561
+ textarea . text ( function ( i , text ) { return textarea [ i ] . value } )
562
+
563
+ // Preserve select values
564
+ findAll ( container , "select" ) . each ( function ( i , elem ) {
565
+ elem = $ ( elem ) ;
566
+ var values = $ ( elem ) . val ( ) ;
567
+ elem . find ( 'option[selected]' ) . attr ( 'selected' , false ) ;
568
+ elem . find ( 'option' ) . filter ( function ( ) {
569
+ return ( $ . inArray ( this . value , values ) !== - 1 ) ;
570
+ } ) . attr ( 'selected' , true ) ;
571
+ } )
572
+
559
573
var cloned = container . clone ( )
560
574
// Unmark script tags as already being eval'd so they can get executed again
561
575
// when restored from cache. HAXX: Uses jQuery internal method.
You can’t perform that action at this time.
0 commit comments