我似乎无法根据文档销毁CKEdit的实例.
考虑以下:
<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>
Run Code Online (Sandbox Code Playgroud)
当destroy()运行时,CKEDITOR.remove(hEd); 被称为.多次单击create()会在屏幕上生成多个CKEditor实例,但它们的实例不再出现在CKEDITOR.instances中.
我错过了什么吗?
让我们说这是我的代码:
<div class="editor" contenteditable></div>
// This is working for me
$('.editor').click(function(){
$(this).ckeditor();
});
// This is the problem
$('.editor').on('focusout', function(){
$(this).ckeditorDestroy(); // What will destroy ckeditor?
});
Run Code Online (Sandbox Code Playgroud)
我知道这个功能不存在,但我没有发现什么工作?