Remove CKEdit Instance
Asked Answered
B

3

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?

Bucksaw answered 6/6, 2010 at 18:37 Comment(0)
F
41

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

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

Fugere answered 7/6, 2010 at 8:11 Comment(3)
Followed a bad snippet. Thanks for setting me straight.Bucksaw
@Fugere Thanks for this - you just saved me raging :)Riannon
Yes, that's right. If you use CKEDITOR.remove() then instance isn't destroyed. You need to call sth like: instance.destroy() to remove old one.Sivia
A
1

Simple solution

CKEDITOR.instances['textareaId'].destory()
Atrocity answered 11/9, 2020 at 20:1 Comment(0)
G
-1

You must use:

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

CKEDITOR.instances['tx1'] = false;

Garman answered 15/12, 2017 at 12:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.