I have array of data that I want to append to an existing table. So, I am basically adding rows to a table by cloning the last row.
1) var clonedRow = $("#tableId" tr:last-child").clone(true);
While looping through the array of data, I set new values for each columns in the clonedRow
2)
$("td", clonedRow).eq(1).html("new data");
$("td", clonedRow).eq(2).html("new data");
and append to the table.
3) $"#tableId").append(clonedRow);
The loop continues (cloning, inserting values, appending...).
I thought it might be faster if I append outside of the loop, so I created a documentFragment
4) var docFrag = document.createDocumentFragment();
and appended clonedRow to the fragment instead of the table
5) docFrag.appendChild(clonedRow);
And then when it was all completed, I would append the document fragment to the table:
6) $("#"+gridID).appendChild(frag);
The problem is that I am getting HierarchyRequestError right where I am appending the row to the document fragment (step 5). Can anyone tell me how to fix this?