On Aug 17, 4:25 am, "Erik Beeson" <[EMAIL PROTECTED]> wrote: > You don't really want multiple fields with the same ID though, do you? > I think .clone() will help you:
No, but I strategically and intentionally left that in to get this exact feedback. :-) Specifically, the id question, which depending on how the submit is done, I might want to keep them all the same to allow for global operations (i.e, verification and packing of fields), and then possible during the final serialization, create your sequential names for the NV (name/value) pairs. > The initial $('<input>') bit creates a DOM node. Adding it the first > time adds it to the DOM, but adding it subsequent times is actually > "moving" it. If you did: > > inputBox.appendTo('#myForm1'); > inputBox.appendTo('#myForm2'); > inputBox.appendTo('#myForm1'); > > I think you would find that the element would bounce back and forth > (with adequate between those calls obviously). Oh interesting. > Sorting DOM nodes works the same way. You grab a reference to them, > sort them outside of the DOM, and reinsert them all back in the same > place they came from. They'll come out sorted because reinserting them > (via append() or some such) is actually doing more of a "move": > > $('#parent').children().sort().appendTo('#parent'); > > If you don't do the finally .appendTo(), you will have sorted them in > memory, but not in the DOM. > > Anyways, a little off topic there. I hope that answers your question. Maybe, but informative. :-)