Related to: http://dev.ckeditor.com/ticket/5441
Is there any way I can properly destroy() a CKEditor in 3.6.1 after it has already been removed from the DOM?
It's a very common pattern to have a form that is submitted by ajax (a div is updated) and that the user must keep submitting the form until they fill out all of the inputs correctly. The problem is, the new editor has the same name as the one that just disappeared, so this causes an error.
If I could just destroy the existing editor with the same name before creating a new one, problem solved. I tried this (where {$name} is the name of the editor):
<script type='text/javascript'> if (typeof CKEDITOR.instances != 'undefined' && typeof CKEDITOR.instances['{$name}'] != 'undefined') { CKEDITOR.instances['{$name}'].destroy(); } </script>
But an error always occurs (i.contentWindow is null).
The bug fix ticket here http://dev.ckeditor.com/ticket/5441 makes it seem like I should be able to do this, and having to destroy all editors in a div before an ajax update occurs is a pain. I didn't have to do that with FCKeditor. Is there something else I need to do to fix this? Or is this just a limitation of the destroy() function?
I'm using firefox 3.6.18
Re: destroy - errors when instance removed from DOM