3
votes

I am trying to trigger a widget's dialog after inserting html in the ck editor - html that is upcast to widget.

For example, say my widget has this template: <div class="mywidget">...</div>. The widget also has a working dialog (double clicking the widget in editor pops the dialog alright).

Somewhere else in my code I insert <div class="mywidget">...</div> into the editor and this becomes a widget. So far so good.

But what I need at this point is to trigger the widget's dialog and I was unable to do this...

I tried adding editor.execCommand('mywidget') in widget's init function but I just get an "uncaught exception".

What's also important is that more of these widgets can be inserted into the editor so I need to trigger just the newly inserted one's dialog.

I am pretty much lost now and I couldn't find anything in the docs so any help would be very much appreciated.

Using ckeditor 4.3, btw.

1

1 Answers

5
votes

Ok, after quite some digging in the docs and a lot of trial and error, I found the answer:

In widget's init function:

init: function() {
    this.on('ready', function() {
        this.edit();
    });
}

Easy in retrospective but not so obvious when you don't know where to look. Hope this helps someone.