Bug Tracker

Opened 14 years ago

Closed 14 years ago

#4382 closed bug (duplicate)

[regression] Append with multiple elements doesn't bind events

Reported by: Blak Owned by: brandon
Priority: minor Milestone: 1.4
Component: event Version: 1.3.2
Keywords: regression append event Cc:
Blocked by: Blocking:

Description

When attempting to use append to add a button (complete with click event handler) to an element, the button appears however the click event is 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

Change History (2)

comment:1 Changed 14 years ago by Blak

Whoops, not used Trac before, they really should make it a little more obvious that you've already created a ticket when you tick add attachment on the new dialog...

Mark this as a dupe as I've added a little more detail and a test case to #4383

comment:2 Changed 14 years ago by dmethvin

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.