How to properly destroy CKEditor instance?

前端 未结 7 2169
无人及你
无人及你 2020-12-09 02:41

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 th

7条回答
  •  难免孤独
    2020-12-09 03:26

    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();
    

提交回复
热议问题