简体   繁体   English

TinyMce - 无法读取未定义的属性'add'

[英]TinyMce - Cannot read property 'add' of undefined

Official page tinymce for event onChange here 官方网页tinymce for event onChange here here

<script>
    tinymce.init({
    selector: "textarea",
    language: "ru",
    plugins: [
        "advlist autolink lists link charmap anchor",
        "searchreplace fullscreen",
        "insertdatetime paste"
    ],
    toolbar: "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link",
    setup : function(ed) {
        ed.onChange.add(function(ed, l) {
            console.debug('Editor contents was modified. Contents: ' + l.content);
        });
    }
});
</script>

i use this code but tinymce not working and in console i see error Cannot read property 'add' of undefined ... 我使用这段代码,但无法工作,在控制台中我看到错误Cannot read property 'add' of undefined ...

Tell me please why code not working nd how will be right ? 请告诉我为什么代码不能正常工作怎么样?

The function for the onChange event that you have works with TinyMCE 3.x version If you are working with TinyMCE 4.x version, the onChange function has this form: 您使用TinyMCE 3.x版本的onChange事件的函数如果您使用的是TinyMCE 4.x版本,则onChange函数具有以下形式:

tinymce.init({
    ...
    setup: function(editor) {
        editor.on('change', function(e) {
            console.log('change event', e);
        });
    }
});

You can see this function in the Oficial Page here . 您可以在此处的官方页面中查看此功能。

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

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