How to call the function of the TinyMCE plugin?

how can i call the function of the tinymce plugin?

 tinymce.activeEditor.plugins.customplugin.customfunction(customvar);

does not work!

+5
source share
2 answers

tinymce.activeEditor.plugins.customplugin.customfunction (customvar);

is the correct way to call such a function. Keep in mind that tinymce.activeEditoryou must install already for its use. tinymce.activeEditorset when the user clicks in the editor, for example. Otherwise use

tinymce.get('your_editor_id_here').plugins.customplugin.customfunction(customvar);

Perhaps there is another reason why your function call does not work: The function you want to call must be defined as a function getInfo, _saveand _nodeChangeto save the plugin (see assembly tinymce developer to test this plugin in the plugins directory.).

:

(function() {
    tinymce.create('tinymce.plugins.Save', {
        init : function(ed, url) {
           ...
        },

        getInfo : function() {
                   ...
        },

        // Private methods

        _nodeChange : function(ed, cm, n) {
                   ...
        },

        // Private methods
                   ...
        _save : function() {

        }
    });

    // Register plugin
    tinymce.PluginManager.add('save', tinymce.plugins.Save);
})();

getInfo , javascript:

tinymce.get('your_editor_id_here').plugins.save.getInfo();
+3

, , self.

tinymce.PluginManager.add('myplugin', function(editor) {
    var self = this;
    var self.myFunction = myFunction(); // Put function into self!

    function myFunction() {
        console.log('Hello world!');
    }
}

:

tinymce.get('your_editor_id_here').plugins.myplugin.myFunction();
+1

All Articles