I'm getting an error when trying to create the second instance of an editor using replace(). It errors in firefox and chrome, but shock! Horror! works in IE8!
Any ideas what this might be? I though it might be my custom save plugin but it happens when I remove that
UPDATE: Seems its the way I'm attaching my notification event. I need the editor to call me back so I created a plugin and added a custom event to the CKEDITOR object:
My plugin
So I can handle some stuff before destroying the editor. If I remove this line I don't get the error! Which brings me back to my question of a few weeks ago. Ho can I set up custom event for plug-ins to call back on?
Error From Firebug
Editor creation Code
Any ideas what this might be? I though it might be my custom save plugin but it happens when I remove that
UPDATE: Seems its the way I'm attaching my notification event. I need the editor to call me back so I created a plugin and added a custom event to the CKEDITOR object:
//add the callback function editor.saveCallback = myCallback;
My plugin
(function() { var a = { modes: { wysiwyg: 1, source: 1 }, exec: function(editor) { //add the callback function to the editor before calling if (editor.saveCallback) { editor.saveCallback(editor); } } }, b = 'AjaxSave'; CKEDITOR.plugins.add(b, { init: function(c) { var d = c.addCommand(b, a); d.modes = { wysiwyg: true }; c.ui.addButton('AjaxSave', { label: c.lang.save, command: b, icon: this.path + 'images/disk.png' }); } }); })();
So I can handle some stuff before destroying the editor. If I remove this line I don't get the error! Which brings me back to my question of a few weeks ago. Ho can I set up custom event for plug-ins to call back on?
Error From Firebug
i.contentWindow is null p(Object name=selectionChange sender=Object editor=Object)CKEditor.js (line 70) anonymous(Object _=Object elementMode=1 element=Object name=CKEdit, Object selection=Object path=Object, function(), function())CKEditor.js (line 6) anonymous("selectionChange", Object selection=Object path=Object, Object _=Object elementMode=1 element=Object name=CKEdit)CKEditor.js (line 6) anonymous("selectionChange", Object selection=Object path=Object)CKEditor.js (line 7) l()CKEditor.js (line 80) anonymous()CKEditor.js (line 9) [Break on this error] l+=m.y;var n=j.getScrollPosition().y;j.$...',width:'100%',baseFloatZIndex:10000};\r\nCKEditor.js (line 18)
Editor creation Code
function replaceDiv(div, callback) { if (editor) { editor.destroy(); editor = null; } editor = CKEDITOR.replace(div); //add the callback function editor.saveCallback = callback; }
CKEDITOR.editorConfig = function(config) { config.toolbar = 'Normal'; config.uiColor = '#E3DCEB'; config.toolbar = 'LiveEdit'; config.contentsCss = '/css/global.css'; config.font_names = 'Times;Georgia;Garamond;Helvetica;Verdana;Trebuchet;Impact;Monospace'; //override font style to write out class attribute rather than span style wrapper config.font_style = { element: 'span', attributes: {'class': '#(family)'}, overrides: [{ element: 'font', attributes: { 'face': null}}] }; config.extraPlugins = "AjaxSave"; //adding my plugin config.toolbar_Normal = [ ['Source', '-', 'Templates'], ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', 'SpellChecker', 'Scayt'], ['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'], ['Maximize', 'ShowBlocks'],['HorizontalRule','PageBreak'], '/', ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript'], ['NumberedList', 'BulletedList', 'Outdent', 'Indent', 'Blockquote'], ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], ['Link', 'Unlink', 'Anchor'], '/', ['Image', 'Flash', 'Table', 'SpecialChar'],['Styles', 'Format', 'Font', 'FontSize'], ['TextColor', 'BGColor'] ]; config.toolbar_LiveEdit = [ ['Source', '-', 'Templates', 'AjaxSave'], ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', 'SpellChecker', 'Scayt'], ['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'], ['Maximize', 'ShowBlocks'], ['HorizontalRule', 'PageBreak'], '/', ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript'], ['NumberedList', 'BulletedList', 'Outdent', 'Indent', 'Blockquote'], ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], ['Link', 'Unlink', 'Anchor'], '/', ['Image', 'Flash', 'Table', 'SpecialChar'], ['Styles', 'Format', 'Font', 'FontSize'], ['TextColor', 'BGColor'] ]; };
Re: Error creating second instance of CK
The error occurs under the destroy function on the o.moveToElementText(m.$); line. If I add a try{}catch{} statement around the section everything continues as normal. Any ideas how to file this as a bug! Bit of a non-descript thing!
Re: Error creating second instance of CK
Does anyone know how to get round it without modifying the code?
Re: Error creating second instance of CK
Upgraded to CK 3.0.2 and this bug is still there!
Re: Error creating second instance of CK