#13043 closed bug (notabug)
append fails with HierarchyRequestError when cloned objects are cached and later appended
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Scenario: Adding rows to a table by cloning the last row, resetting the input values and adding a change handler to each text input
Assumptions: Given a table defined in the DOM with id="tbl" The table has a minimum of one row defined with one text input in each of one or more cells
This works:
var tbl = $("#tbl")[0];
$(tbl).append($(tbl.rows[tbl.rows.length-1]).clone().find("input:text").val("").change(tableCellTextChanged).end());
This Fails:
var arr = [];
var tbl = $("#tbl")[0]; arr.push($(tbl.rows[tbl.rows.length-1]).clone().find("input:text").val("").change(tableCellTextChanged).end()); $(tbl).append(arr[0]); Throws HierarchyRequestError in the Clean function in JQuery
Using native JavaScript works though:
var arr = []; var tbl = $("#tbl")[0]; arr.push($(tbl.rows[tbl.rows.length-1]).clone().find("input:text").val("").change(tableCellTextChanged).end()[0]);
tbl.appendChild(arr[0]);
Change History (5)
comment:1 Changed 10 years ago by
Owner: | set to [email protected]… |
---|---|
Status: | new → pending |
comment:2 Changed 10 years ago by
Status: | pending → new |
---|
Rows do append to the table object. Here is the URL for my jsfiddle test case. http://jsfiddle.net/ryanmch/W34SW/23/
comment:3 follow-up: 4 Changed 10 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
I reduced your test case. http://jsfiddle.net/dmethvin/W34SW/30/
Try appending either an array of the DOM elements or a jQuery collection containing the DOM elements, but NOT a jQuery collection containing a jQuery collection with the DOM elements. For questions like this in the future, please ask for help on the forum.
comment:4 Changed 10 years ago by
This does not work using JQuery 1.7.2 though. That is the version I specified in the bug. Your fiddle was using the latest JQuery version.
http://jsfiddle.net/ryanmch/W34SW/32/
Replying to dmethvin:
I reduced your test case. http://jsfiddle.net/dmethvin/W34SW/30/
Try appending either an array of the DOM elements or a jQuery collection containing the DOM elements, but NOT a jQuery collection containing a jQuery collection with the DOM elements. For questions like this in the future, please ask for help on the forum.
comment:5 Changed 10 years ago by
I can't tell you what we fixed offhand, but if it works in the current version then that's the one I'd recommend. It does work in 1.8.3. We don't provide patches for old versions.
Please provide a test case in jsFiddle. Also, did you mean to append to the table TBODY? Rows don't under the table element.