Alex004
Alex004

Reputation: 785

CKEditor command on new instance not working

I have the problem that execCommand() does not work immediately after creating the editor

var editor;

function1() {
  editor = CKEDITOR.appendTo('data', config);
  editor.execCommand('maximize'); // does not work
}

function2() {
  editor.execCommand('maximize'); // works
}

If I call function2 after function1 it works. What do I miss or not understand?

Upvotes: 0

Views: 309

Answers (1)

oleq
oleq

Reputation: 15895

CKEditor loads asynchronously; it won't exec your actions until it's ready. Use editor#instanceReady event listener:

config.on = {
    'instanceReady': function( evt ) {
        this.execCommand('maximize');
    }
};

Upvotes: 0

Related Questions