Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling save button enabled/disabled state programmatically

Tags:

ckeditor

How would I enable/disable the save button of CKEditor using external JS? I don't want to remove it completely, just change the appearance between gray and colored icon so that it's more user friendly.

My save button is generated like so:

CKEDITOR.plugins.registered['save'] =
{
    init : function( editor )
    {
        var command = editor.addCommand( 'save', {
            modes : { wysiwyg:1, source:1 },
            exec : function( editor ) {
                if(My.Own.CheckDirty())
                    My.Own.Save();
                else
                    alert("No changes.");
            }
        });
        editor.ui.addButton( 'Save',{label : '',command : 'save'});
    }
}
like image 415
Joel Peltonen Avatar asked Oct 23 '12 08:10

Joel Peltonen


1 Answers

Here you go:

For 3.6.x:

CKEDITOR.instances.yourEditorInstance.getCommand( 'save' ).disable();
CKEDITOR.instances.yourEditorInstance.getCommand( 'save' ).enable();

For 4.x:

CKEDITOR.instances.yourEditorInstance.commands.save.disable();
CKEDITOR.instances.yourEditorInstance.commands.save.enable();
like image 140
oleq Avatar answered Sep 29 '22 13:09

oleq