TinyMCE 在隐藏 textarea 之前不会从 textarea 中抓取内容 [英] TinyMCE not grabbing content from textarea before hiding that textarea

查看:28
本文介绍了TinyMCE 在隐藏 textarea 之前不会从 textarea 中抓取内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个页面上运行了一个 TinyMCE 实例,可以让我编辑现有帖子.我查询数据库,并用存储的文本填充变量 $content.然后我有以下 HTML:

I have an instance of TinyMCE running on a page that enables me to edit existing posts. I query the db, and populate the variable $content with the stored text. I then have the following HTML:

<label for="content">Content:</label>
<textarea name="content" class="post-content" rows="<?php echo $settings_rows; ?>" ><?php echo $content; ?></textarea>

TinyMCE 显示为编辑器,没问题,但不显示存储在 $content 中的文本.没有外围的 <p> 标记,并且正在填充 $content 变量(为了确定,我在 textarea 之外回显了它,Firebug 显示了隐藏的文本区域也被填充).

TinyMCE is displaying as an editor, no problem, but is not displaying the text stored in $content. There are no outlying <p> tags, and the $content variable is being populated (I echo'd it outside of the textarea to be sure, and Firebug shows the hidden textarea also being populated).

编辑器init如下:

    tinyMCE.init({
            mode : "textareas",
            theme : "advanced",
            plugins : "advimage",
            theme_advanced_buttons1 : "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2 : "cut,copy,paste,pastetext,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,|,image,hr,removeformat,visualaid,charmap,code",
            theme_advanced_buttons3 : "",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            theme_advanced_resizing : true,
            editor_selector : "post-content"
    });

谁能告诉我为什么这不起作用?我已经在其他页面上使用过它,使用这个精确的系统,没有任何问题.

Can anyone advise me why this isn't working? I've used it on other pages, using this exact system, without a hitch.

编辑

作为 P.S.相关的CSS如下:

As a P.S. the relevant CSS is as follows:

.post-content {
padding: 3px 10px;
width: 90%;
}

推荐答案

请尝试以下操作.给你的 textarea ideditor1",使用 mode: "exact", 而不是 mode: "textareas",并按以下方式初始化您的编辑器(暂时将 tinymce init 保留在原处,但在以下几行之前)

Try the following. Give your textarea the id "editor1", use mode: "exact", instead of mode: "textareas", and initialize your editor the following way (keep the tinymce init where it is for now, but before the following lines)

$(document).ready(function() {
    tinyMCE.execCommand('mceAddControl', false, 'editor1');
}

这篇关于TinyMCE 在隐藏 textarea 之前不会从 textarea 中抓取内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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