1

A extended question from here

The clone function seems to be able to copy every element but not the hidden inputs Now everything looks like this after clone:

<input id="_denominations[0].id.reference" class="removableHiddenOrder" type="hidden" name="denominations[0].id.reference" value="">
<input id="_denominations[0].denomination" class="removableHiddenDenom" type="hidden" name="denominations[0].denomination" value="">

the value="" is a problem. It should carry the value from original target element. I know clone() by default is clone(false), but use clone(true) doesn't help much.

Community
  • 1
  • 1
Dreamer
  • 7,333
  • 24
  • 99
  • 179
  • 2
    You'll have to add the value manually ! – adeneo Mar 22 '13 at 20:41
  • @MattStone That seems to be a different question entirely. It relates to problems with a specific broswer when cloning elements that are themselves clones. The answer doesn't help here. – Asad Saeeduddin Mar 22 '13 at 20:59
  • @Dreamer Unless I'm missing something, those two elements had an empty attribute value to begin with (from looking at your earlier question). What is the problem? – Asad Saeeduddin Mar 22 '13 at 21:00
  • @Asad Thanks. I pick up the wrong element for example, just updated the post, I am sure original element has hidden elements with valid value. – Dreamer Mar 22 '13 at 21:13
  • @Dreamer So the value attribute gets changed to the current value of the input when you clone it. You want the value attribute to stay empty. Is that correct? – Asad Saeeduddin Mar 22 '13 at 21:17
  • @Asad No, I want them to stay the same with original node's hidden value. the original node has valid non-null hidden value. I want to clone the node with copy of all of the original hidden values, but the duplicate node comes with all hidden node value as null... which is no good to my situation. – Dreamer Mar 22 '13 at 21:24
  • @Dreamer In the code you have posted, the hidden inputs values are unchanged, not null. – Asad Saeeduddin Mar 22 '13 at 21:27
  • @Asad my bad, post is updated again... – Dreamer Mar 22 '13 at 21:28
  • 2
    @Dreamer That doesn't seem to be the case. See [this](http://jsfiddle.net/Ykqga/) jsfiddle demonstration, where cloning the original input carries over the value attribute. – Asad Saeeduddin Mar 22 '13 at 21:32
  • @Asad Thank you. I just notice I am on jQuery 1.4.4, not sure how that make a difference on the result... – Dreamer Mar 22 '13 at 21:39
  • @Dreamer You should use a more recent version of jQuery. – Asad Saeeduddin Mar 22 '13 at 21:45

0 Answers0