简体   繁体   English

CKEDITOR 4文本插入问题

[英]CKEDITOR 4 text insert issue

I am using ckeditor v4.6.2 and need to add text dynamically like below 我正在使用ckeditor v4.6.2,需要动态添加文本,如下所示

<textarea name="body" id="editor1" class="form-control"></textarea>

CKEDITOR.replace('editor1', customConfig);
var text = "this is home";
CKEDITOR.instances.editor1.insertHtml(text);

but doesnot work but in browser console I see 但不起作用,但在浏览器控制台中我看到了

TypeError: E is undefined

Where is my problem? 我的问题在哪里?

You need to wait for CKEditor instance to become ready for interaction. 您需要等待CKEditor实例准备好进行交互。 Use instanceReady event: 使用instanceReady事件:

CKEDITOR.replace('editor1', customConfig);
CKEDITOR.instances.editor1.on('instanceReady', function(evt) {
    evt.editor.insertHtml("this is home");
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM