CKEditor不会加载php变量

时间:2013-05-10 14:34:17

标签: php html textarea ckeditor

我在PHP页面中添加了一个textarea控件,使用CKEditor的类 现在,如果textarea加载为空,则CKEditor可以正常工作。但是,如果我尝试在textarea中加载PHP变量,页面会正确显示编辑器,但它不会显示内容(并且编辑器似乎被阻止)。 这是我的代码:

<div id="dialog-edit" title="Edit" style="display: none;">
    <table cellspacing="10">
        <tr>
            <td>
                <table>
                <form method="post" name="form">
                <tr>
                        <td>

                </td>
                <td>

                </td>
                <td>

                </td>
                </tr>
                </table>                    
                <br/>
                <textarea class="ckeditor" name="html" id="html" style="width: 766px; height: 390px; margin-left: 6px;"><?php echo htmlentities($html) ?></textarea><br/>
                <input type="submit" name="save" id="save" value="Salva modifiche" class="button" />
                </form>
            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">
    function showDialogEdit()
    {
        $( "#dialog-edit" ).dialog({

                width: 680,
                height: 620,
                modal: true,
                open: function(event, ui)
                {

                }
            });
    }
</script>

textarea必须将内容(保存在MySQL数据库中作为HTML代码)显示在textarea中,但它不会这样做。
是什么造成了这个问题?
感谢。

1 个答案:

答案 0 :(得分:5)

请尝试按照CKEditor演示文件夹中的“替换为代码”示例进行操作:

  1. 从textarea中删除“ckeditor”类。
  2. 修改jQueryUI对话框“open”事件,在打开对话框后触发
  3. http://jsfiddle.net/mblase75/g2HFn/4/

    $("#dialog-edit").dialog({
        width: 680,
        height: 620,
        modal: true,
        open: function (event, ui) {
            CKEDITOR.replace('html');
        }
    });