Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CKEditor close dialog

Tags:

ckeditor

I'm trying to call close function for CKEditor dialog box from my custom plugin. Just like it happens when you are clicking on smile in "smileys" plugin, but I can't find out how can I do the same in my own plugin. Thanx for reply!

I've got the solution. In my plugin I needed to call close function from "CKEDITOR.dialog.add" in "onLoad" section. So, I have to do this:

CKEDITOR.dialog.add( 'plugin_name', function( editor ){
    onLoad: function( event ){
        [...some code...]
        event.sender.hide();
    }
}
like image 947
Rick Avatar asked Aug 10 '10 14:08

Rick


2 Answers

I propose you do it the same way it is done by CKEditor Dialog plugin internally. See line 535 in plugin.js

By clicking the button or firing the cancel event you ensure correct handling by the plugin.

Code sample:

// If there's a Cancel button, click it, else just fire the cancel event and hide the dialog.
        button = CKEDITOR.dialog.getCurrent().getButton( 'cancel' );
        if ( button )
            CKEDITOR.tools.setTimeout( button.click, 0, button );
        else {
            if ( CKEDITOR.dialog.getCurrent().fire( 'cancel', { hide : true } ).hide !== false )
            CKEDITOR.dialog.getCurrent().hide();
        }
like image 98
Didi Avatar answered Oct 24 '22 07:10

Didi


CKEDITOR.dialog.getCurrent().hide()

like image 43
Micah Avatar answered Oct 24 '22 08:10

Micah