Software-controlled save button on / off

How to enable or disable the CKEditor save button using external JS? I don’t want to completely remove it, just change the appearance between the gray and color icon to make it more convenient.

My save button is created like this:

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'}); } } 
+6
source share
1 answer

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(); 
+16
source

All Articles