Hi,
I have in my application to create aninctance of the eitor, after click on a button, show the editor in a new div, and destroy it after editing. It works fine. I used the sample of ajax.html form the install package as sample. But obviously the sample dosn't work fine. The instance will not be destroyed. the script will build for each click a new Instance of editor.
My proper problem is i have to config the editor, and this works only for the first click. after second click, the editor will be shown in the default configuration.
the original code from the ck-sample:
the part "ditor.config.toolbar ... " is done by me.
as i described above, the editor appears at first with the choosen buttons. all following appearances of the editor are in the full (default) version.
i hope you can help me to solve the problem.
I have in my application to create aninctance of the eitor, after click on a button, show the editor in a new div, and destroy it after editing. It works fine. I used the sample of ajax.html form the install package as sample. But obviously the sample dosn't work fine. The instance will not be destroyed. the script will build for each click a new Instance of editor.
My proper problem is i have to config the editor, and this works only for the first click. after second click, the editor will be shown in the default configuration.
the original code from the ck-sample:
function createEditor() { if ( editor ) return; var html = document.getElementById( 'editorcontents' ).innerHTML; // Create a new editor inside the <div id="editor"> editor = CKEDITOR.appendTo( 'editor' ); editor.setData( html ); editor.config.toolbar = [ ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink', '-', 'Cut','Copy','Paste','-','Outdent','Indent','Blockquote', '-', 'Subscript','Superscript', '-', 'TextColor'], ['UIColor'] ]; // This sample may break here if the ckeditor_basic.js is used. In such case, the following code should be used instead: /* if ( editor.setData ) editor.setData( html ); else { CKEDITOR.on( 'loaded', function() { editor.setData( html ); }); } */ } function removeEditor() { if ( !editor ) return; // Retrieve the editor contents. In an Ajax application, this data would be // sent to the server or used in any other way. document.getElementById( 'editorcontents' ).innerHTML = editor.getData(); document.getElementById( 'contents' ).style.display = ''; // Destroy the editor. editor.destroy(); editor = null; }
the part "ditor.config.toolbar ... " is done by me.
as i described above, the editor appears at first with the choosen buttons. all following appearances of the editor are in the full (default) version.
i hope you can help me to solve the problem.
Re: destroy an editorInstance
Jean
Re: destroy an editorInstance
Your problem is that you can't change the toolbar configuration after the instance has been created. The first time it takes slightly longer to create the editor as it has to load all the resources, but the next time it's done straight away so your editor.config.toolbar is useless.
@jhotterb
Please, DON'T use CKEDITOR.remove. You must call the destroy() method of the instance that you want to remove.
Re: destroy an editorInstance
@alfonsoml at first thans for answer. actually the behavior you described sound like a bug. I should be able to define the property of the each instance of the object i create.
How ever I solve my problem by using the jQuery Adapter as folow:
it works very fine. The memory using increase a little bit, by each creating of a new instance, but it isn't dramatic.
Re: destroy an editorInstance
And you can, but you must do it in the proper way. Once the toolbar is created, any change to the config object won't be reflected as it's a static property (and as long as IE6 and IE7 are supported it will remain that way).
Instead you must call
http://docs.cksource.com/ckeditor_api/s ... #.appendTo
Re: destroy an editorInstance
- define config
- create editor with this config
- the editor will appear in my configuration
- destroy the editor
- click for a new editor
- define the config
- create editor with this config
- the editor will appear in full configuration
but anyway with jQuery it works fine
Re: destroy an editorInstance
I don't understand if you are asking something, stating some problem or just adding a comment because I don't need any need to use jQuery for this simple task
Re: destroy an editorInstance
if they are a better way, it would be great if you could modify the sample "ajax.html" in this way, that the editor will be created with modifyed config.