简体   繁体   中英

TinyMce - Cannot read property 'add' of undefined

Official page tinymce for event onChange 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 ...

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.init({
    ...
    setup: function(editor) {
        editor.on('change', function(e) {
            console.log('change event', e);
        });
    }
});

You can see this function in the Oficial Page here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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