Iftakharul Alam
Iftakharul Alam

Reputation: 3321

CKEDITOR 4 text insert issue

I am using ckeditor v4.6.2 and need to add text dynamically like below

<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?

Upvotes: 0

Views: 292

Answers (1)

Wizard
Wizard

Reputation: 3151

You need to wait for CKEditor instance to become ready for interaction. Use instanceReady event:

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

Upvotes: 1

Related Questions