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
Fist, let me apologize for posting without an answer.
I'm having almost the same problem here, but i believe the cause is the same. Mine is a form loaded with xajax, first time the form is replaced successfully, but when try to reload the form, the textarea vanishes but isnt replaced by the ckeditor. I didn't even get to submit anything, just change pages, when i get back, it's gone... This happens when i try with replace. The appendTo loads everytime, but i didnt figure yet how to get its value and get it sent hitting the form submit by post method along with the other fields as if it was a normal field.
I guess we are more or less in the same boat here.. anyone else can give some help?
Re: CKEditor instance disappears after AJAX form submit
If anyone is interested in a solution that worked for this issue:
http://cksource.com/forums/viewtopic.php?f=11&t=15499&p=39483&hilit=destroy+ckeditor#p39483
Solved the issue using an example from the link above:
After a succesful form submission this piece of javascript solved the issue:
Re: CKEditor instance disappears after AJAX form submit
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.