Controlling save button enabled/disabled state programmatically

允我心安 提交于 2019-12-04 12:08:46

问题


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'});
    }
}

回答1:


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();


来源:https://stackoverflow.com/questions/13026122/controlling-save-button-enabled-disabled-state-programmatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!