Side navigation
#7037 closed bug (fixed)
Opened September 15, 2010 04:56PM UTC
Closed September 20, 2011 12:31PM UTC
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
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');
Attachments (0)
Change History (19)
Changed October 12, 2010 04:57PM UTC by comment:1
Changed October 15, 2010 01:11AM UTC by comment:2
priority: | → high |
---|---|
status: | new → open |
Changed October 27, 2010 10:09PM UTC by comment:3
milestone: | 1.4.3 → 1.4.5 |
---|
Retargeting for next release.
Changed January 02, 2011 12:57AM UTC by comment:4
owner: | → rwaldron |
---|---|
status: | open → assigned |
Changed January 17, 2011 07:00PM UTC by comment:5
milestone: | 1.4.5 → 1.5 |
---|
Changed March 07, 2011 05:10PM UTC by comment:7
milestone: | → 1.next |
---|---|
priority: | high → blocker |
Changed March 07, 2011 05:11PM UTC by comment:8
milestone: | 1.next → 1.6 |
---|---|
owner: | rwaldron → dmethvin |
Changed April 25, 2011 04:07PM UTC by comment:9
milestone: | 1.6 → 1.next |
---|
Let's bump this and discuss it for 1.7.
Changed May 22, 2011 07:27PM UTC by comment:10
keywords: | clone events mouseover mouseout → clone,events,mouseover,mouseout,1.7-discuss |
---|
Nominating ticket for 1.7 discussion.
Changed May 22, 2011 10:04PM UTC by comment:11
description: | 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'); \ \ → 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');\ \ |
---|
+1, Seems like a bug, should be fixed
Changed May 23, 2011 12:11AM UTC by comment:12
+1, It's a bug
Changed May 23, 2011 02:01AM UTC by comment:13
description: | 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');\ \ → 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'); \ \ |
---|
+1,
Changed May 23, 2011 03:43AM UTC by comment:14
description: | 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'); \ \ → 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');\ \ |
---|
+1,
Changed June 03, 2011 01:38PM UTC by comment:15
+1, Oof, let's get this fixed.
Changed June 03, 2011 03:11PM UTC by comment:16
+1
Changed June 06, 2011 03:54PM UTC by comment:17
+0
Changed July 12, 2011 02:45PM UTC by comment:18
description: | 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');\ \ → 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'); \ \ |
---|---|
milestone: | 1.next → 1.7 |
Changed September 20, 2011 12:31PM UTC by comment:19
resolution: | → fixed |
---|---|
status: | assigned → closed |
Just noting that this is still an issue in jQuery 1.4.3 rc1