Question

Question about tinymce 4-th version. when I add a button

editor.addButton('cut_tag', {
                type: 'button',
                text: '<cut>',
                name: 'cut_tag',
                id: 'cut_tag',
                icon: false,
                tooltip: 'Вставить cut',
                onclick: function(e){
                    editor.insertContent('[cut]');
                    this.disabled(true);
                    editor.cut_tag_button = this; // hack - store object in var to get object from var later
                }
            });

And I want to execute some code when initializing button, I tried 'oninit', 'oncreate', 'setup', etc. but no effect. Please advice, thank you.

Was it helpful?

Solution

You need to move the onclick event outside the add button object.

editor.addButton(...);
editor.on('click', function(e) {
    alert('Insert logic here');
});

The syntax has also changed a little. This TinyMCE Migration Guide might help explain more.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top