From 7d0c18034e1a7967c1aabc84e66e6fd020cd541d Mon Sep 17 00:00:00 2001 From: jeresig Date: Tue, 22 Dec 2009 12:04:17 -0500 Subject: [PATCH] Explicitly re-bind the events on clone. Copying over the data isn't enough. Fixes #5681. --- src/manipulation.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/manipulation.js b/src/manipulation.js index 5109cf093..27bc0b46b 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -283,7 +283,18 @@ function cloneCopyEvent(orig, ret) { return; } - jQuery.data( this, jQuery.data( orig[i++] ) ); + var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData.events; + + if ( events ) { + delete curData.handle; + curData.events = {}; + + for ( var type in events ) { + for ( var handler in events[ type ] ) { + jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); + } + } + } }); } -- 2.39.5