Jack James
Jack James

Reputation: 5372

Run jQuery plugin on TinyMCE content

I have a jQuery plugin (jQuery.fn.myJQueryPlugin) that loads on a page that also loads a TinyMCE editor.

Is there a way I can get the plugin to work on the content of the TinyMCE editor (via a TinyMCE plugin)?

I've tried something along the lines of

tinymce.PluginManager.add( 'myTinyMCEPlugin', function( editor ) {
    editor.on('PostProcess', function(event){
        editor.getWin().parent.jQuery(".trigger-class").myJQueryPlugin();
    });
});

but that doesn't seem to work

Upvotes: 0

Views: 299

Answers (1)

Jack James
Jack James

Reputation: 5372

ok, it turns out, it can be done:

tinymce.PluginManager.add( 'myTinyMCEPlugin', function( editor ) {
    editor.on('PostProcess', function(event){
        // get jQuery from parent window
        $ = editor.getWin().parent.jQuery;
        $(".trigger-class", editor.getDoc()).myJQueryPlugin();
    });
});

Upvotes: 1

Related Questions