Issue:
On an AJAX form submit, the correct value of the CKEditor is succesully posted and inserted into a database. However, after the first submission the editor completely disappears (including the original text field).
Background:
* The CKEditor instance is initated by the CKEDITOR.replace method of an existing text field.
* Tried using the CKEDITOR.appendTo approach to dynamically create the editor - however the same issue occurs.
* The text field is located in a seperate page which is pulled into the main page via AJAX.
* The updated contents of the CKEditor are obtained via the following snippet:
My guess would be that the CKEditor instance needs to be destroyed and recreated after submission? However, I have searched, read and experimented extensively and have not been able to rectify the issue.
Can anyone please provide some help with this?
Thanks in advance.
On an AJAX form submit, the correct value of the CKEditor is succesully posted and inserted into a database. However, after the first submission the editor completely disappears (including the original text field).
Background:
* The CKEditor instance is initated by the CKEDITOR.replace method of an existing text field.
* Tried using the CKEDITOR.appendTo approach to dynamically create the editor - however the same issue occurs.
* The text field is located in a seperate page which is pulled into the main page via AJAX.
* The updated contents of the CKEditor are obtained via the following snippet:
for(var name in CKEDITOR.instances) CKEDITOR.instances[name].updateElement();
My guess would be that the CKEditor instance needs to be destroyed and recreated after submission? However, I have searched, read and experimented extensively and have not been able to rectify the issue.
Can anyone please provide some help with this?
Thanks in advance.

Re: CKEditor instance disappears after AJAX form submit
Re: CKEditor instance disappears after AJAX form submit
http://cksource.com/forums/viewtopic.php?f=11&t=15499&p=39483&hilit=destroy+ckeditor#p39483
http://docs.fckeditor.net/ckeditor_api/symbols/CKEDITOR.editor.html#destroy
Re: CKEditor instance disappears after AJAX form submit
<form id='myForm' ... > <textarea id='myTextArea'></textarea> <script type='text/javascript'> try { CKEDITOR.replace('myTextArea'); } catch(e){} </script> <input type="submit" name="submit" value="Save" onclick="document.getElementById('myTextArea').value=CKEDITOR.instances.myTextArea.getData(); CKEDITOR.instances.myTextArea.destroy()" /> </form>Re: CKEditor instance disappears after AJAX form submit
Re: CKEditor instance disappears after AJAX form submit
The solution that worked for me was as follows:
if (CKEDITOR.instances['Field1']) {
CKEDITOR.remove(CKEDITOR.instances['Field1']);
}
CKEDITOR.replace( 'Field1');
Hope this helps,
Adam
Thank you
This solution also worked for me well.