clonenode

How to Maintain Correct Javascript Event After Using cloneNode(true)

I have a form element that contains multiple lines of inputs. Think of each line as attributes of a new object that I want to create in my web application. And, I want to be able to create multiple new objects in one HTTP POST. I'm using Javascript's built-in cloneNode(true) method to clone each line. The problem is that each input-lin...

How efficient is element.cloneNode(true) (deep clone)?

I'm building the HTML code within an XML DOM object to be used as the contents of the innerHTML of a div element using an XSL template. Traditionally we create a new XML DOM document and add the input parameters as XML Elements for the transform via javascript. This is all very time-consuming as we are basically hand picking the data fro...

documentFragment.cloneNode(true) doesn't clone jQuery data

I have a documentFragment with several child nodes containing some .data() added like so: myDocumentFragment = document.createDocumentFragment(); for(...) { myDocumentFragment.appendChild( $('<a></a>').addClass('button') .attr('href', 'javascript:void(0)') .html('click me') .data('rowData', { 'id': 103, 'test': ...

Copy all childNodes to an other element. In javascript native way.

Hello I have to change "unknown" contents of XML. The structure and content itself is valid. Original <blabla foo="bar"> <aa>asas</aa> <ff> <cc> <dd /> </cc> </ff> <gg attr2="2"> </gg> ... ... </blabla> becomes <blabla foo="bar"> <magic> <aa>asas</aa> <ff> ...

cloneNode in internet explorer

While executing the following code IE throws the error -- Object doesn't support this property or method -- referring to the cloneNode() method. 'i' is the loop counter, source and dest are both HTML select elements. dest.options[dest.options.length] = source.options[i].cloneNode( true ); FF and Chrome behave as expected. Any ideas ...

Moving a node from one XML document to another using SimpleXML

I realize that my request is not possible using just SimpleXML -- that much I did figure out. Here is what I tried: $newXML = simplexml_load_file($filePath); $domNewXML = dom_import_simplexml($newXML); $domItem = dom_import_simplexml($items[$itemQty]); <-- item I want to move $domNewItem = $domItem->cloneNode(true); $newNode = $domNew...

Loading a form with input text rows equal to a passed variable number using the clone function

All I want to do (and it would be easy enough with PHP, but I'm pushing myself to learn more javascript and jQuery and front end coding right now by modifying scripts to understand what they do) is to build a form with the same number of rows as the "Seats" variable stipulates from a previous form. Then the registrant can enter the name...