Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am running CKeditor 3.4 on a pretty simple page. I am having a problem (sometimes) where when I call document.main_form.submit(), it will not send along the contents of the textarea. After some reading, it sounds like CKeditor is not destroying properly. I tried to manually destroy it before I save the form, but wasn't able to call it. The weird thing is, it works sometimes, but not others. I'm on Chrome, so that may be screwing with things, but the same thing happens in Firefox.

How can I properly destroy the CKeditor so that it always sends the textarea data in POST. Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
549 views
Welcome To Ask or Share your Answers For Others

1 Answer

I had this problem. What a pain.

To properly destroy the editor instance, try

if (CKEDITOR.instances.myInstanceName) CKEDITOR.instances.myInstanceName.destroy();

From the documentation here

I solved the missing content issue by assigning the contents of the editor to a hidden field prior to postback. I'm using ASP.Net, but it should work universally.

in the client-side click handler of the submit button, call

if (CKEDITOR.instances.myInstanceName)
    document.getElementById('hiddenField').value = CKEDITOR.instances.getData();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...