Side navigation
#4383 closed bug (duplicate)
Opened March 19, 2009 10:55AM UTC
Closed December 13, 2010 02:49AM UTC
Last modified January 31, 2011 05:54PM UTC
[regression] Append with multiple elements doesn't bind events
Reported by: | Blak | Owned by: | Blak |
---|---|---|---|
Priority: | high | Milestone: | 1.5 |
Component: | core | Version: | 1.5 |
Keywords: | regression append event | Cc: | |
Blocked by: | Blocking: |
Description
When attempting to use append to add a button (complete with click event handler) to multiple elements, the button appears however the click events are not bound.
This only appears to effect browsers that use addEventListener, in IE it works as expected.
The following does not bind an event to the buttons
var button = $("<input type='button' value='Click Me!' />").click(function(){ alert("hello"); }); //there are 2 divs inside #append $("#append div").append(button);
However using
button.appendTo("#appendto div");
works as expected in all browsers tested (FF3, Opera9, Safari3 (Win), IE6, IE7).
Both methods work when using jQuery 1.2.6 or if you're appending to a single element.
Attachments (1)
Change History (8)
Changed March 21, 2009 02:20AM UTC by comment:1
component: | event → core |
---|---|
owner: | brandon → john |
Changed October 29, 2010 05:14PM UTC by comment:2
owner: | john → Blak |
---|---|
priority: | minor → low |
status: | new → pending |
Please provide a reduced jsFiddle test case, thanks!
Additionally, test against the jQuery 0 GIT version to ensure the issue still exists.
Changed November 01, 2010 12:48PM UTC by comment:3
status: | pending → new |
---|
Tested against jQuery 0 GIT and the problems still exists.
jsFiddle test case can be found at: http://jsfiddle.net/PC5vu/2/
Changed November 01, 2010 09:01PM UTC by comment:4
milestone: | 1.4 → 1.4.5 |
---|---|
priority: | low → high |
status: | new → open |
version: | 1.3.2 → 1.4.4rc |
Changed December 13, 2010 02:49AM UTC by comment:5
resolution: | → duplicate |
---|---|
status: | open → closed |
Changed January 31, 2011 05:53PM UTC by comment:7
version: | 1.4.4rc → 1.5 |
---|
There wasn't a 1.4.5 release, was actually 1.5.
Changed January 31, 2011 05:54PM UTC by comment:8
milestone: | 1.4.5 → 1.5 |
---|
There was no 1.4.5 release, was actually 1.5.
The problem seems to be that
goes through the internal function; that uses the DOM cloneNode method which doesn't copy events. The method uses jQuery's method, which does copy events.Although the end result is that events are lost, this is more of a core DOM manipulation issue so I'll reassign it there.