TinyMCE:隐藏的textarea

时间:2013-04-02 08:18:35

标签: html css tinymce rich-text-editor

我尝试在我的网站上设置tinyMCE。 这是我的设置:

<script type="text/javascript" src="extensions/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
    tinyMCE.init({
        // General options
        mode : "exact",
        elements: "mceContent",
        language : "ru",
        theme : "advanced",
        forced_root_block : false,
        force_br_newlines : true,
        force_p_newlines : false,

        plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,formatselect,forecolor,backcolor,link,unlink,justifyleft,justifycenter,justifyright,bullist,numlist,|,pasteword,pastetext,table,image,|,undo,redo,|,code,fullscreen",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true,
        height: 400,
        width: 680,

        skin : "o2k7",
        skin_variant : "blue",
        theme_advanced_toolbar_align : "left",
        relative_urls : false
    });
</script>

这是我的HTML代码:

<textarea class="span8" name="mceContent" id="mceContent" rows="15" 
    style="width: 40em; height: 20em" >
        {$mceContent}
</textarea>

当我打开此页面时,文本区域被隐藏。这是我在浏览器中看到的HTML代码:

<textarea class="span8" name="mceContent" id="mceContent" rows="15" 
style="width: 40em; height: 20em; visibility: hidden;">                 
</textarea> 

那么,我该如何解决这个问题呢?

2 个答案:

答案 0 :(得分:0)

这不是问题。 bcoz你已经将 元素:&#34; mceContent&#34; 的值传递给了tinymce构造函数,通过这样做,插件将隐藏匹配的元素,它将改为编辑器

答案 1 :(得分:0)

在正确加载DOM之前,您正在运行tinymce.init()。您需要将init()包装在document.ready中:

document.addEventListener('DomContentLoaded', function(){

    tinyMCE.init({
        // your init options
    });

});