Bug Tracker

Opened 13 years ago

Closed 12 years ago

#7037 closed bug (fixed)

Duplicate mouseover and mouseout events added to cloned element.

Reported by: patrickwhalen Owned by: dmethvin
Priority: blocker Milestone: 1.7
Component: manipulation Version: 1.4.2
Keywords: clone, events, mouseover, mouseout, 1.7-discuss Cc:
Blocked by: Blocking:

Description (last modified by dmethvin)

When cloning an element that has mouseenter or mouseleave events, the clone will receive a duplicate mouseover and mouseout event causing the handler to double-fire.

So if the jQuery.cache shows this for the original:

mouseenter: Array(1)

mouseover: Array(1)

mouseleave: Array(1)

mouseout: Array(1)

the clone will have:

mouseenter: Array(1)

mouseover: Array(2)

mouseleave: Array(1)

mouseout: Array(2)


Test: http://jsfiddle.net/9y7tp/

The hover for the original element will toggleClass the "blue" class properly and show one alert.

The hover for the clone double-fires the handler, so the toggleClass is called again, and you get 2 alerts.

var $hoverbox = $('.hover').hover(function(e) {

$('#box').toggleClass('blue');

alert(e.type);

});

$hoverbox.clone(true).text("Hover clone").appendTo('body');

Change History (19)

comment:1 Changed 12 years ago by patrickwhalen

Just noting that this is still an issue in jQuery 1.4.3 rc1

comment:2 Changed 12 years ago by snover

Priority: high
Status: newopen

comment:3 Changed 12 years ago by snover

Milestone: 1.4.31.4.5

Retargeting for next release.

comment:4 Changed 12 years ago by Rick Waldron

Owner: set to Rick Waldron
Status: openassigned

comment:5 Changed 12 years ago by dmethvin

Milestone: 1.4.51.5

comment:6 Changed 12 years ago by Rick Waldron

#8397 is a duplicate of this ticket.

comment:7 Changed 12 years ago by john

Milestone: 1.next
Priority: highblocker

comment:8 Changed 12 years ago by john

Milestone: 1.next1.6
Owner: changed from Rick Waldron to dmethvin

comment:9 Changed 12 years ago by john

Milestone: 1.61.next

Let's bump this and discuss it for 1.7.

comment:10 Changed 12 years ago by john

Keywords: 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:11 Changed 12 years ago by Rick Waldron

Description: modified (diff)

+1, Seems like a bug, should be fixed

comment:12 Changed 12 years ago by jaubourg

+1, It's a bug

comment:13 Changed 12 years ago by ajpiano

Description: modified (diff)

+1,

comment:14 Changed 12 years ago by Timmy Willison

Description: modified (diff)

+1,

comment:15 Changed 12 years ago by john

+1, Oof, let's get this fixed.

comment:16 Changed 12 years ago by scottgonzalez

+1

comment:17 Changed 12 years ago by jzaefferer

+0

comment:18 Changed 12 years ago by dmethvin

Description: modified (diff)
Milestone: 1.next1.7

comment:19 Changed 12 years ago by dmethvin

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.