简体   繁体   English

TinyMCE在fancyBox弹出窗口中不起作用

[英]TinyMCE doesn't work inside fancyBox popup

If I open my textarea field inside a fancyBox window inline like so: 如果我像这样在内联的fancyBox窗口中打开我的textarea字段:

<a href="#someId" class="fancybox">Edit</a>

text doesn't want to be displayed inside TinyMCE plugin I use. 文本不希望在我使用的TinyMCE插件内显示。 Text is already inside those textareas but it is greyed out if I look in the console and the TinyMCE plugin is unresponsive. 文本已经在这些文本区域中,但是如果我在控制台中查看并且TinyMCE插件没有响应,则该文本显示为灰色。 Pic: here. 图片: 这里。 I understand I need to initialize TinyMCE inside popup window but I don't know how? 我知道我需要在弹出窗口中初始化TinyMCE,但我不知道如何?

I already initialized TinyMCE for all textareas and I initialized fancyBox in my script but thats it. 我已经为所有文本区域初始化了TinyMCE,并在脚本中初始化了fancyBox,仅此而已。

You want to initialize TinyMCE when the content of the popup is loaded. 您希望在加载弹出窗口的内容时初始化TinyMCE。 So what you want is to look in the Fancybox documentation and look for callback-functions. 因此,您想要的是在Fancybox文档中查找并寻找回调函数。

A callback function is a function that is triggered when a specific event occurrs. 回调函数是在发生特定事件时触发的函数。

In the documentation ( http://fancybox.net/api ) you will find there is an onComplete callback: "Will be called once the content is displayed". 在文档( http://fancybox.net/api )中,您将找到一个onComplete回调:“一旦显示内容,就会调用”。

So I think this should work: 所以我认为这应该工作:

$(document).ready(function() {

    $("a.fancybox").fancybox({
        'onComplete': function(){
            alert('place your tinymce init code here');
        }
    });

});

Here we define an anomynous callback function for the onComplete event of "a.fancybox". 在这里,我们为“ a.fancybox”的onComplete事件定义了一个统一的回调函数。 In this function you can place you tinyMCE init stuff. 在此功能中,您可以将tinyMCE初始化内容放入。

Note that you might have to do some more coding, because you probably want to load TinyMCE only the first time the overlay is opened. 请注意,您可能需要做更多的编码,因为您可能只想在第一次打开叠加层时加载TinyMCE。 The second time it is already loaded and you don't want to initialize TinyMCE again. 第二次已经加载,您不想再次初始化TinyMCE。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM