TinyMCE with ajax tabs

前端 未结 5 1856
面向向阳花
面向向阳花 2021-01-16 04:49

I\'m using tabs component of JQuery UI 1.8, and I\'m loading content of tabs via ajax (html content). In one of this tabs I\'m using tinyMCE component, and when I load this

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-16 05:31

    I found the solution to my problem. The initialization of tinymce must be in load event of jquery tabs, like this:

    $("div#tabs").tabs ({collapsible: false
                        ,selected:    -1
                        ,fx: {opacity: 'toggle'}
                        ,load: function (event, ui) {
    
                           // Tab with tinyMCE
                           if (ui.index == 0) {
                              tinyMCE.init({mode: "none",
                                            theme: "advanced",
                                            theme_advanced_toolbar_location: "top",
                                            theme_advanced_toolbar_align: "left"
                                           });
                              tinyMCE.execCommand ('mceAddControl', false, 'text_area_id');
                           }
                           else {
                             tinyMCE.triggerSave();
                             tinyMCE.execCommand('mceFocus', false, 'text_area_id');
                             tinyMCE.execCommand('mceRemoveControl', false, 'text_area_id');
                           }
                         }
                  });
    

    I hope this helps others. Besides, if the content of the textarea is load via ajax, the command:

    tinyMCE.triggerSave();
    

    is not necesary.

提交回复
热议问题