【问题标题】:Disable a Dialog Button in CKEditor在 CKEditor 中禁用对话框按钮
【发布时间】:2017-01-26 15:15:47
【问题描述】:

我尝试为 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_disabled)。

也很奇怪:如果我把 abbreviation-replace-button 变成一个复选框,这个复选框就会被禁用(没有进一步的代码修改)。

我的问题:

  • 如何禁用插件对话框上的按钮?
  • 为什么复选框被禁用而按钮却没有?
  • 我的错误在哪里?

【问题讨论】:

    标签: javascript button dialog ckeditor


    【解决方案1】:

    我认为你需要调用一个特殊的方法来禁用按钮, 即`disableButton('btn')

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

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

    你可以试试

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

    【讨论】:

      猜你喜欢
      • 2020-07-09
      • 2013-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-18
      • 2013-08-20
      • 2012-01-04
      相关资源
      最近更新 更多