From: jeresig Date: Tue, 22 Dec 2009 17:04:17 +0000 (-0500) Subject: Explicitly re-bind the events on clone. Copying over the data isn't enough. Fixes... X-Git-Url: http://git.asbjorn.biz/?p=jquery.git;a=commitdiff_plain;h=7d0c18034e1a7967c1aabc84e66e6fd020cd541d Explicitly re-bind the events on clone. Copying over the data isn't enough. Fixes #5681. --- diff --git a/src/manipulation.js b/src/manipulation.js index 5109cf0..27bc0b4 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 ); + } + } + } }); }