Opened 11 years ago

Closed 11 years ago

#9763 closed Bug (invalid)

Exception from editor after it is destroyed

Reported by: Martin Häcker Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Cc:

Description

I've got the peculiar situation that in a very ajax heavy app sometimes I have to get rid of editors almost immediately after it has been added to the dom.

This works fine in most circumstances by calling editor.destroy() before removing the dom element that hosts it.

However If this happens on the first editor that is created, I always get an error out of core/editor.js:291 from onConfigLoad which still gets a callback after the configuration has loaded.

I'm not sure what the right fix is, as destroy() already seems to deregister the editor from all further events (though it doesn't catch this one).

This patch helped me work around the issue for now - but it is something that should be included in CKEditor I believe.

diff --git a/vendor/ckeditor-4.0/core/editor.js b/vendor/ckeditor-4.0/core/editor.js
index 2f31d13..5578ec1 100644
--- a/vendor/ckeditor-4.0/core/editor.js
+++ b/vendor/ckeditor-4.0/core/editor.js
@@ -280,6 +280,8 @@
        // ##### END: Config Privates
 
        function onConfigLoaded( editor ) {
+               if ( ! editor.element) return;
+               
                // Set config related properties.
                /**
                 * Indicates the read-only state of this editor. This is a read-only property.

To reproduce it you would use something along the lines of this

var holder = $('<div><div id=editor>')
editor = CKEDITOR.replace(holder.find('#editor'))
editor.destroy()
// wait for the config to have loaded

Change History (1)

comment:1 Changed 11 years ago by Jakub Ś

Resolution: invalid
Status: newclosed

This should rather look like this:

holder = $('<div><div id=editor>')
var editor = CKEDITOR.replace(holder.find('#editor'))
editor.on('instanceReady', function(evt){
evt.editor.destroy();
});

Many things can be broken that way (not only this one):

editor = CKEDITOR.replace(holder.find('#editor'))
editor.destroy()
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy