CKEditor instance already exists

前端 未结 30 3491
刺人心
刺人心 2020-11-27 11:24

I am using jquery dialogs to present forms (fetched via AJAX). On some forms I am using a CKEditor for the textareas. The editor displays fine on the first load.

Whe

30条回答
  •  無奈伤痛
    2020-11-27 11:55

    The i.contentWindow is null error seems to occur when calling destroy on an editor instance that was tied to a textarea no longer in the DOM.

    CKEDITORY.destroy takes a parameter noUpdate.

    The APIdoc states:

    If the instance is replacing a DOM element, this parameter indicates whether or not to update the element with the instance contents.

    So, to avoid the error, either call destroy before removing the textarea element from the DOM, or call destory(true) to avoid trying to update the non-existent DOM element.

    if (CKEDITOR.instances['textarea_name']) {
       CKEDITOR.instances['textarea_name'].destroy(true);
    }
    

    (using version 3.6.2 with jQuery adapter)

提交回复
热议问题