Tick Twitch
Tick Twitch

Reputation: 566

How To open thickbox, onclicking Tinymce Button with dynamic content from ajax

I have added a tinymce button to my tinymce editor.but instead of opening the tinymce default modal (editor.addCommand),I want to open Thickbox with ajax content.I have searched many answers on stackoverflow, but didn't make it out.

Here is my code

(function() {
    tinymce.PluginManager.add('smart_event', function( editor, url ) {
        var shortcode_tag = 'smart_event';

        editor.addCommand('smart_event_panel_popup', function( ui, v ){
            var columns = '4';
            if(v.columns){
                columns = v.columns;
            }
            var style = '';
            if(v.style){
                style = v.style;
            }
            editor.windowManager.open({
                title: 'Smart Event Shortcode',
                body: [

                    //...........

                ],
                onsubmit: function(e){
                    // var scode = '[' + shortcode_tag +' columns="' + e.data.columns + '"' + ' style="' + e.data.style + '"' + ' posts_per_page"'+ e.data.posts_per_page +'"' + ' sortby="'+ e.data.sortby +'"' + ' range="'+ e.data.range +'"' + ' pagination="'+e.data.pagination + '"' +' filters="'+e.data.filters + '"' +']';

                    editor.insertContent( scode );
                }
            });
        });


        editor.addButton('smart_event', {
            image: seventadmindata.imagesurl + 'icon.png',
            tooltip: 'Insert Smart Event Shortcode',
            onclick: function(){
                editor.execCommand('smart_event_panel_popup','',{
                    columns : '4',
                    style : '1',
                });
            }
        });
    });
})();

How can I add Thickbox on click with an ajax callback?

Upvotes: 1

Views: 134

Answers (0)

Related Questions