Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#13043 closed bug (notabug)

append fails with HierarchyRequestError when cloned objects are cached and later appended

Reported by: ryanmch@… Owned by: ryanmch@…
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 7 years ago by dmethvin

Owner: set to ryanmch@…
Status: newpending

Please provide a test case in jsFiddle. Also, did you mean to append to the table TBODY? Rows don't under the table element.

comment:2 Changed 7 years ago by ryanmch@…

Status: pendingnew

Rows do append to the table object. Here is the URL for my jsfiddle test case. http://jsfiddle.net/ryanmch/W34SW/23/

comment:3 Changed 7 years ago by dmethvin

Resolution: notabug
Status: newclosed

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 in reply to:  3 Changed 7 years ago by ryanmch@…

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 7 years ago by dmethvin

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.

Note: See TracTickets for help on using tickets.