具有多AJAX刷新和TinyMCE的问题 [英] Having issues with Multiple AJAX refresh and TinyMCE

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

问题描述

所以,我遇到了这种predicament。

So I'm running into this predicament.

<SCRIPT src="../js/tiny_mce/tiny_mce.js"></script>
<SCRIPT type="text/javascript">
   tinyMCE.init({
        mode : "textareas",
        theme : "simple"
   });
</SCRIPT>
<SCRIPT src="../js/admin.js"></script>

以上是叫我的PHP页面。

The above is called on my PHP page.

我然后调用

var request = $.ajax(
{
   url:"getEvents.php",
   type:"POST",
   data:{'method':'showevents'},
   dataType:"html"
   }).done(function(msg){
        $('#eventlistbody').html(msg);
   }); 

   setTimeout(
        function(){
            $(".mceSimple").each(function(){
              tinyMCE.execCommand("mceAddControl",false, this.id);
           })
   },2000); 

这加载了一堆文本域的..... TinyMCE的将在第一时间就returns..when我点击它再次运行上面,并返回他们不再有TinyMCE的附属于他们的文本区域重载加载的所有文字领域。 我不知道为什么它的第一次,而不是随后的时间。

this loads a bunch of textareas..... the tinyMCE will load on all the text areas the first time it returns..when I click on the reload which runs the above again and returns the text areas they no longer have the tinyMCE attached to them. I'm not sure why it works the first time and not subsequent times.

推荐答案

您应该关闭TinyMCE的正确之前,你为了能够重新初始化TinyMCE的编辑器重装作出后重装。这是必要的,因为TinyMCE的不喜欢周围的DOM来拖动。并初始化编辑器实例可能有一个一个唯一的ID(使用重载将迫使TinyMCE的尝试initliaze第二编辑器相同的ID - 这将失败)

You should shut down tinymce correctly before you reload in order to be able to reinitialize a tinymce editor after the reload has been made. This is necessary because tinymce does not like to be dragged around the dom. And initialized editor instances may have one one unique id (using reload will force tinymce to try to initliaze a second editor with the same id - which will fail).

Tinymce3: 要关闭一个edtor实例使用:

Tinymce3: To shut down an edtor instance use:

tinymce.execCommand('mceRemoveControl',true, editor_id);

要重新初始化使用

tinymce.execCommand('mceAddControl',true, editor_id);

Tinymce4: 要关闭一个edtor实例使用:

Tinymce4: To shut down an edtor instance use:

tinymce.execCommand('mceRemoveEditor',true,editor_id);

要重新初始化使用

tinymce.execCommand('mceAddEditor',true,editor_id);

这篇关于具有多AJAX刷新和TinyMCE的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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