22

I can't seem to destroy instances of CKEdit per the documentation.

Consider the following:

<input name="txt1" type="text" id="txt1" /><br />
<a href="javascript:void(0);" onclick="create()">Create</a><br />
<a href="javascript:void(0);" onclick="destroy()">Destroy</a>
<script type= "text/javascript" >
<!--
function create() {
    var hEd = CKEDITOR.instances['txt1'];
    if (hEd) {
        CKEDITOR.remove(hEd);
    }
    hEd = CKEDITOR.replace('txt1');
}
function destroy(){
    var hEd = CKEDITOR.instances['txt1'];
    if (hEd) {
        CKEDITOR.remove(hEd);
    }
}
-->
</script>

When destroy() runs, CKEDITOR.remove(hEd); is being called. Multiple clicks to create() produce multiple instances of CKEditor on screen, but their instances no longer appear in CKEDITOR.instances.

Am I missing something?

Laramie
  • 5,457
  • 2
  • 39
  • 46

3 Answers3

41

You must use hEd.destroy (editor.destroy()).

CKEDITOR.remove() is for internal use as stated in the API.

AlfonsoML
  • 12,634
  • 2
  • 46
  • 53
1

Simple solution

CKEDITOR.instances['textareaId'].destory()
-1

You must use:

<textarea name="tx1" id="tx1" rows="15" cols="106"></textarea>

CKEDITOR.instances['tx1'] = false;