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 )
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
comment:2 Changed 12 years ago by
Priority: | → high |
---|---|
Status: | new → open |
comment:4 Changed 12 years ago by
Owner: | set to Rick Waldron |
---|---|
Status: | open → assigned |
comment:5 Changed 12 years ago by
Milestone: | 1.4.5 → 1.5 |
---|
comment:7 Changed 12 years ago by
Milestone: | → 1.next |
---|---|
Priority: | high → blocker |
comment:8 Changed 12 years ago by
Milestone: | 1.next → 1.6 |
---|---|
Owner: | changed from Rick Waldron to dmethvin |
comment:10 Changed 12 years ago by
Keywords: | 1.7-discuss added |
---|
Nominating ticket for 1.7 discussion.
comment:11 Changed 12 years ago by
Description: | modified (diff) |
---|
+1, Seems like a bug, should be fixed
comment:18 Changed 12 years ago by
Description: | modified (diff) |
---|---|
Milestone: | 1.next → 1.7 |
comment:19 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Just noting that this is still an issue in jQuery 1.4.3 rc1