Cheok Yan Cheng
Cheok Yan Cheng

Reputation: 42670

CKEditor plugin - How to fire DialogCommand in a proper way

Previously, by clicking a toolbar button, I will launch my custom dialog immediately.

editor.addCommand('launch', new CKEDITOR.dialogCommand('myLaunchDialog'));

However, now, I wish to

  1. Perform network activity first when toolbar button is clicked.
  2. Upon completion of network activity, launch the custom dialog.

Here's what I'm trying to do

editor.addCommand('launch', {
    exec : function( editor ) {
        performNetworkActivity(function() {
            // Network activity done!

            var command = new CKEDITOR.dialogCommand('myLaunchDialog');
            // Hem... doesn't work
            editor.execCommand(command);
        });
    }},
    async : false
});

Note, execCommand doesn't work for me.

var command = new CKEDITOR.dialogCommand('myLaunchDialog');
// Hem... doesn't work
editor.execCommand(command);

I even tried

var command = new CKEDITOR.dialogCommand('myLaunchDialog');
command.enable();
command.exec();

Doesn't work still...

May I know what is the proper way to launch custom dialog programmatic-ally?

My dialog is defined as

CKEDITOR.dialog.add('myLaunchDialog', function( editor ) {

Upvotes: 1

Views: 893

Answers (1)

Cheok Yan Cheng
Cheok Yan Cheng

Reputation: 42670

Here's the proper way to fire dialog command.

var command = new CKEDITOR.dialogCommand('myLaunchDialog');
editor.addCommand('_myLaunchDialog', command);

editor.addCommand('launch', {
    exec : function( editor ) {
        performNetworkActivity(function() {
            // Network activity done!

            editor.execCommand("_myLaunchDialog");
        });
    }},
    async : false
});

Upvotes: 1

Related Questions