Ticket #5566 (closed bug: fixed)
domManip fails to copy events when cloning elements
| Reported by: | dalangalma | Owned by: | snover |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.5 |
| Component: | manipulation | Version: | 1.4.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
I am creating a "button" element, adding a click handler to it, then attaching it to every one of multiple "li" elements by selecting all of the "li"s and appending the "button" element. When I do that, none of the buttons retain their click element. This worked in jQuery 1.2.6, then broke in 1.3.1 (see #3966 and #4161). I've verified the problem with the attached demo in jQuery 1.3.2 and a build from GitHub from 11/29/09.
Attachments
Change History
Changed 3 years ago by dalangalma
-
attachment
jquery-1.3.2-append-handlers.html
added
comment:1 Changed 3 years ago by dalangalma
Here's a live demo: http://benhollis.net/experiments/browserdemos/jquery-1.3.2-append-handlers.html
comment:2 Changed 3 years ago by dmethvin
Still a problem in 1.4a1. domManip uses DOM cloneNode when appending to multiple elements, that looks like where the events are dropped. It looks like cloneCopyEvent might come in handy.
comment:3 Changed 3 years ago by dalangalma
This is still broken on 1.4.4 though by now it's been regressed for so long that maybe the docs just need to be updated.
comment:4 Changed 3 years ago by snover
- Priority changed from major to blocker
- Status changed from new to open
- Version changed from 1.3.2 to 1.4.4
- Milestone changed from 1.4 to 1.5
This should work.
comment:6 Changed 2 years ago by snover
- Owner set to snover
- Status changed from open to assigned
- Summary changed from Can't create an element, assign an event handler, then append it to multiple elements. to domManip fails to copy events when cloning elements
- Component changed from core to manipulation
- Milestone changed from 1.5 to 1.4.5
comment:8 Changed 2 years ago by john
- Status changed from assigned to closed
- Resolution set to fixed
Landed.
comment:9 Changed 2 years ago by jeresig
Backing out cec68e2b00d86357c18b576cbaed52cc1ea42a74, was causing serialize tests to fail. Un-fixes #5566.
Changeset: 29616e60c88bf300f4b2ee4ad1a89a8ac6481027
comment:10 Changed 2 years ago by john
- Status changed from closed to reopened
- Resolution fixed deleted
comment:11 Changed 2 years ago by Colin Snover
- Status changed from reopened to closed
- Resolution set to fixed
Merge branch 'bug5566' into csnover-bug5566. Fixes #4386, #5566, #6997.
Conflicts:
src/manipulation.js test/unit/manipulation.js
Changeset: 4fae75d575b20d887e4a273c7991c55f8821a62c
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Test case for the bug.