简体   繁体   English

在CKEditor中禁用对话框按钮

[英]Disable a Dialog Button in CKEditor

I try to write a plugin for the CKEditor (Version 4.x), with a Dialog UI element. 我尝试使用Dialog UI元素为CKEditor(版本4.x)编写插件。

the definition of the dialog looks like: 对话框的定义如下:

CKEDITOR.dialog.add('abbrDialog', function(editor) {
return {
    title: editor.lang.abbr.title,
    label: editor.lang.abbr.title,
    minWidth: 400,
    minHeight: 200,

    contents: [{
            id: 'abbreviation-dialog',
            label: editor.lang.abbr.label,
            elements: [
              {
                id: 'abbreviation-found-label',
                type: 'html',
                label: editor.lang.abbr.found,
                html: '<span id="foundLabelId">'+ editor.lang.abbr.found + '<\/span>'
              },
              {
                id: 'abbreviation-current-item',
                type: 'html',
                label: editor.lang.abbr.currentLabel,
                html: '<span id="currentLabelId">'+ editor.lang.abbr.currentLabel + '<\/span>'
              },
              {
                id: 'abbreviation-replace-button',
                type: 'checkbox',
                label: editor.lang.abbr.replaceButton,
                onClick : function() {
                  replaceAbbreviation(editor.lang.abbr.currentLabel, editor.lang.abbr.noMore);
                }
              },
              {
                id: 'abbreviation-next-button',
                type: 'button',
                label: editor.lang.abbr.nextButton,
                onClick : function() {
                  nextAbbreviation(editor.lang.abbr.currentLabel, editor.lang.abbr.noMore);
                }
              },
              {
                id: 'abbreviation-all-button',
                type: 'button',
                label: editor.lang.abbr.allButton,
                onClick : function() {
                  replaceAllAbbreviations(editor.lang.abbr.currentLabel, editor.lang.abbr.noMore);
                  //alert('Replace all!!');
                }
              }]
        }],

    buttons: [CKEDITOR.dialog.okButton],

    onShow: function() {
      initDialog(editor.lang.abbr.found, editor.lang.abbr.currentLabel);
    },

    onOk: function() {
      // nothing to do
    }

In one function i try to disable a button. 在一个功能中,我尝试禁用按钮。 This looks like: 看起来像:

CKEDITOR.dialog.getCurrent().getContentElement("abbreviation-dialog", "abbreviation-replace-button").disable();

Unfortunately this button gets not disable (but the additional CSS-class cke_disabled is added). 不幸的是,这个按钮没有被禁用(但是添加了附加的CSS类cke_disabled )。

Also strange: if i turn that abbreviation-replace-button into a checkbox, this checkbox gets disabled (with no further code modifications). 也很奇怪:如果我将abbreviation-replace-button变成一个复选框,则此复选框将被禁用(无需进一步的代码修改)。

My Questions: 我的问题:

  • How can i disable a button on a plugin dialog? 如何禁用插件对话框上的按钮?
  • Why gets the checkbox disabled but the button not? 为什么禁用此复选框但不禁用该按钮?
  • Where is my mistake? 我的错误在哪里?

I think you need to call a special method to disable buttons, ie `disableButton('btn') 我认为您需要调用一种特殊的方法来禁用按钮,即`disableButton('btn')

you can disable ok or cancel button by following way 您可以通过以下方式禁用“ ok或“ cancel按钮

CKEDITOR.dialog.getCurrent().disableButton('ok')
CKEDITOR.dialog.getCurrent().disableButton('cancel')

in your case you can try 您可以尝试

CKEDITOR.dialog.getCurrent().disableButton('abbreviation-next-button')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM