TinyMCE与Ajax标签 [英] TinyMCE with ajax tabs

查看:115
本文介绍了TinyMCE与Ajax标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JQuery UI 1.8的选项卡组件,并且正在通过ajax(html内容)加载选项卡的内容.在其中一个选项卡中,我使用的是tinyMCE组件,并且在我第一次加载该选项卡时,微型程序会正确初始化,但是如果导航至其他选项卡,然后再次调用该选项卡,则该微型程序会崩溃.

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 tab the first time, the tiny initializates correctly but if I navegate to other tab and I recall the tab again the tiny breaks down.

当tiny_mce.js的导入不在选项卡的内容之外时,会发生这种情况.当我将导入移动到tab调用中时,微小对象未加载,因为它似乎尚未初始化.

This occurs when the import of tiny_mce.js is outside the contents of tabs. When I move the import into tab call, the tiny didn't load because it seems to be not initialized.

问题是:如何在ajax标签中初始化tiny?

The question is: how can initialize tiny in an ajax tab?

谢谢.

推荐答案

我找到了解决问题的方法. tinymce的初始化必须在 jquery选项卡 load 事件中进行,例如:

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');
                       }
                     }
              });

我希望这对其他人有帮助.此外,如果textarea的内容是通过ajax加载的,则命令:

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

tinyMCE.triggerSave();

不是必需的.

这篇关于TinyMCE与Ajax标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆