Index: _source/core/editor.js =================================================================== --- _source/core/editor.js (revision 3794) +++ _source/core/editor.js Mon Jul 20 01:36:26 CST 2009 @@ -283,32 +283,44 @@ var form = element.$.form && new CKEDITOR.dom.element( element.$.form ); if ( form ) { - form.on( 'submit', function() + function onSubmit() - { - editor.updateElement(); + { + editor.updateElement(); - }); + } + form.on( 'submit',onSubmit ); // Setup the submit function because it doesn't fire the // "submit" event. if ( !form.$.submit.nodeName ) { - form.$.submit = CKEDITOR.tools.override( form.$.submit, function( originalSubmit ) + function submitHandler( originalSubmit ) - { - return function() - { - editor.updateElement(); + { + return function() + { + editor.updateElement(); - // For IE, the DOM submit function is not a - // function, so we need thid check. - if ( originalSubmit.apply ) - originalSubmit.apply( this, arguments ); - else - originalSubmit(); - }; + // For IE, the DOM submit function is not a + // function, so we need thid check. + if ( originalSubmit.apply ) + originalSubmit.apply( this, arguments ); + else + originalSubmit(); + }; - }); - } + } + + var originalSubmit = form.$.submit; + form.$.submit = CKEDITOR.tools.override( form.$.submit, submitHandler ); - } + } + + // Remove all 'submit' events registered on form element before destroying.(#3988) + editor.on( 'beforeDestroy', function() + { + form.removeListener( 'submit', onSubmit ); + if ( originalSubmit ) + form.$.submit = originalSubmit; + } ); - } + } + } }; function updateCommandsMode() @@ -447,9 +459,9 @@ */ destroy : function( noUpdate ) { + this.fire( 'beforeDestroy' ); if ( !noUpdate ) this.updateElement(); - this.theme.destroy( this ); CKEDITOR.remove( this ); }, Index: CHANGES.html =================================================================== --- CHANGES.html (revision 3935) +++ CHANGES.html Mon Jul 20 01:42:44 CST 2009 @@ -153,6 +153,7 @@