How to destroy an instance of ckeditor 4

Dung Do Tien Apr 01 2020 195

Hi There,

I have an application to make a comment box look like Facebook comments. This box has many forms to post the comment. I use CKEditor 4 to input, but all editor is generated dynamically by the comment of users.

Every form has a button to remove the form, so how can I destroy CKEditor of that form when it's removed? I used the below command but it not working.

CKEDITOR.remove('EDITOR_ID');

Please tell me if you know any ideal.

Have 1 answer(s) found.
  • CKEditor has provider destroy() function to remove an instance of it. Have some ways to remove one or more Ckeditor as bellow:

    1. Remove one by one with instance name (by id)

    if (CKEDITOR.instances["editorId"]) { // Check null
    	CKEDITOR.instances["editorId"].destroy(); 
    } 

    OR

    if (CKEDITOR.instances.editorId){
      CKEDITOR.instances.editorId.destroy();
    } 

    2. Remove all instance have in the page

    for(var name in CKEDITOR.instances)
    {
        CKEDITOR.instances[name].destroy()
    } 

    In your case, you should generate dynamic id for each CKEditor and when click button Remove and find to CKEditor in that form and get the id of it and remove.

    I hope that useful to you

    Dung Do Tien Apr 02 2020
Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips