Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event when tinymce plugin dialog is closed

tinymce.PluginManager will open a dialog using windowManager.open(). The dialog can be closed manually by using windowManager.close(). This is described by http://www.tinymce.com/wiki.php/api4:class.tinymce.Plugin. The dialog can also be closed by clicking the "X" in the top right corner.

I would like to execute some script whenever the dialog is closed. Seems to me there are two options.

Option 1. Ideally, I can add a callback which would execute whenever ever the dialog is closed. I have searched the documentation, but cannot find out whether this is possible.

Option 2. When ever I manually close the dialog using windowManager.close(), I can add the desired script directly before doing so. It is when the user clicks the X has got me stumped.

Trigger the event which happens when I click the 'x' button on a TinyMCE modal dialog (like the advimage dialog) describes adding an event handler to the X button being clicked. Problem is the event cannot be associated until the dialog is open, and there doesn't seem to be an on open dialog event I can do it at.

How can I execute code whenever the TinyMCE plugin dialog is closed? Thank you

$(".mceClose").click(function() {
    alert('Handler for .click() called.');
});
like image 206
user1032531 Avatar asked Oct 22 '13 18:10

user1032531


People also ask

Is TinyMCE a plugin?

Contents. TinyMCE is an incredibly powerful, flexible and customizable rich text editor. This section will help configure and extend the editor by using TinyMCE plugins.

How do you destroy TinyMCE?

Use tinymce. remove() method to remove TinyMCE editor from the HTML element and again call tinymce. init() on the selector to reinitialize.

How do you get text from TinyMCE editor?

The TinyMCE getContent and setContent methods You can do this using the getContent() API method. Let's say you have initialized the editor on a textarea with id=”myTextarea”. This will return the content in the editor marked up as HTML.


2 Answers

To be precise you should add onClose function as the following:

tinyMCE.activeEditor.windowManager.open({
    ...
    onClose: function() {

    }
});

It cost me a lot of time to find right solution. Hope it will help.

like image 77
Serhii Kukunin Avatar answered Oct 04 '22 08:10

Serhii Kukunin


As described in API reference, close method fires onClose event. So you can try something like:

tinymce.activeEditor.windowManager.onClose.add(function() {...})
like image 35
Vladimir Zaslavsky Avatar answered Oct 04 '22 07:10

Vladimir Zaslavsky