Javascript 禁用CKEditor中的对话框按钮

Javascript 禁用CKEditor中的对话框按钮,javascript,button,dialog,ckeditor,Javascript,Button,Dialog,Ckeditor,我尝试为CKEditor(版本4.x)编写一个带有对话框UI元素的插件 对话框的定义如下所示: CKEDITOR.dialog.add('abbrDialog', function(editor) { return { title: editor.lang.abbr.title, label: editor.lang.abbr.title, minWidth: 400, minHeight: 200, contents: [{ i

我尝试为CKEditor(版本4.x)编写一个带有对话框UI元素的插件

对话框的定义如下所示:

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
    }
CKEDITOR.dialog.getCurrent().getContentElement("abbreviation-dialog", "abbreviation-replace-button").disable();
不幸的是,这个按钮没有被禁用(但是添加了额外的CSS类
cke\u disabled

同样奇怪的是:如果我将
缩写替换按钮
变成一个复选框,这个复选框将被禁用(没有进一步的代码修改)

我的问题是:

  • 如何禁用插件对话框上的按钮
  • 为什么禁用复选框而不禁用按钮
  • 我的错在哪里

    • 我认为您需要调用一种特殊方法来禁用按钮, i、 e.`disableButton('btn'))

      您可以通过以下方式禁用
      ok
      cancel
      按钮

      CKEDITOR.dialog.getCurrent().disableButton('ok')
      CKEDITOR.dialog.getCurrent().disableButton('cancel')
      
      你可以试试看

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