【问题标题】:Tinymce: How to add or modify attributes after (or during) the init phase?Tinymce:如何在初始化阶段之后(或期间)添加或修改属性?
【发布时间】:2022-01-10 21:18:20
【问题描述】:

我需要的基本上是这样的:

 tinymce.init({
     selector: '.tinymce-texteditor',
     plugins: 'code',
     height: 500,

     if (!candEdit) {
       menubar: false,
       toolbar: false,
     }     

   ...

});

果然这段代码是行不通的,不过思路是根据一些外部变量来添加或修改一些属性。

我该怎么做?

【问题讨论】:

    标签: tinymce


    【解决方案1】:

    好的,我知道了。可以对设置方法进行修改:

     tinymce.init({
         selector: '.tinymce-texteditor',
         plugins: 'code',
         height: 500,
         setup: function (editor) {
    
            ...
    
            if (!$('#canEdit').val()) {
                editor.settings.menubar = false;
                editor.settings.toolbar = false;
                editor.settings.readonly = 1;
            } 
          }
    
    
       ...
    
    });
    

    【讨论】:

      猜你喜欢
      • 2018-12-27
      • 1970-01-01
      • 1970-01-01
      • 2017-01-16
      • 1970-01-01
      • 2022-08-13
      • 2012-10-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多