繁体   English   中英

Uncaught TypeError:无法读取未定义的tinymce版本4.x的属性“ add”

[英]Uncaught TypeError: Cannot read property 'add' of undefined tinymce version 4.x

我正在使用微型mce 4.x版本,这是我在html文件中编写的代码

 <script type="text/javascript" src="tinymce/tinymce.min.js"></script>
 <script>
   tinymce.init({
    selector: "textarea#elm1",
    theme: "modern",
    width: 500,
    height: 300,
    plugins: [
         "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
         "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
         "save table contextmenu directionality emoticons template paste textcolor"
   ],
      content_css: "css/content.css",
      toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons", 
       style_formats: [
           {title: 'Bold text', inline: 'b'},
           {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
           {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
           {title: 'Example 1', inline: 'span', classes: 'example1'},
           {title: 'Example 2', inline: 'span', classes: 'example2'},
           {title: 'Table styles'},
           {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
      ],
     setup : function(ed) {
        ed.onBeforeRenderUI.add(function(ed, cm) {
         console.log('add function called');
       });
       ed.onLoadContent.add(function(ed, o) {
           console.log('add function called');
      });
}


}); 

<body>
    <textarea id="elm1" name="area"></textarea>
</body>

我收到错误

未捕获的TypeError:调用onBeforeRenderUI.add()方法时无法读取未定义的属性“ add”

请帮助我解决此问题。 谢谢。

感谢您分享对您有用的解决方案。 但是正确的是:解决您的问题的方法是使用tinymce 4代码(onLoadContent仅适用于tinymce3)。 在这里使用此方法的正确方法是:

 setup : function(ed) {
    ed.on('BeforeRenderUI', function(e) {
     console.log('BeforeRenderUI function called');
   });
   ed.on('LoadContent', function(e) {
       console.log('LoadContent function called');
  });

暂无
暂无

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

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