删除 CKEdit 实例
我似乎无法根据文档销毁 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>
当 destroy() 运行时,CKEDITOR.remove(hEd);正在被呼叫。多次单击 create() 会在屏幕上生成 CKEditor 的多个实例,但它们的实例不再出现在 CKEDITOR.instances 中。
我错过了什么吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须使用 hEd.destroy (editor.destroy()) 。
CKEDITOR.remove() 供内部使用,如 API 中所述。
You must use hEd.destroy (editor.destroy()).
CKEDITOR.remove() is for internal use as stated in the API.
简单的解决方案
Simple solution
您必须使用:
CKEDITOR.instances['tx1'] = false;
You must use:
CKEDITOR.instances['tx1'] = false;