YUI 2.9.0 Chrome中的富文本编辑器填充,然后删除editorHTML

时间:2012-04-12 20:23:35

标签: javascript google-chrome yui rich-text-editor

当双击行或单击“编辑”按钮并选择行时,我将通过数据行中的数据填充YUI RTE。 IE和FF按预期执行,但Chrome填充了html内容(我从chrome的inspect el功能调试中知道这一点),然后几毫秒后,它会删除它。有什么建议??

以下是我如何构建YUI RTE

function CreateRTE() {

    //create the RTE:
    emailEditor = new YAHOO.widget.Editor('txtEmlBody', { width: '468px', height: '200px' });

    //After the Editor renders it, we will hide it so the iframe doesn't bleed through
    emailEditor.on('afterRender', emailEditor.hide);

    //Add the insert token button when the toolbar is loaded
    emailEditor.on('toolbarLoaded', function () {

        //Create the button configuration
        var config = { type: 'menu', label: 'Insert Token', value: 'inserttoken', menu: tokenMenu };

        //Add the button to the toolbar
        emailEditor.toolbar.addButtonToGroup(config, 'insertitem');

        //Add the event handler for a menu item click
        emailEditor.toolbar.on('inserttokenClick', function (ev) { this.execCommand('inserthtml', ev.button.value); }, emailEditor, true);

    });

    //render the editor explicitly into a container within the Dialog's DOM:
    emailEditor.render();


}

这是我在双击行时填充RTE的方法,或者在选择行时单击编辑按钮。

function EditEmail() {

    //Get the record from the datatable
    var dt = grids.tblEmails.dataTable;
    var tr = dt.getSelectedRows()[0];
    var row = dt.getRecord(tr);

    //Populate the form
    YAHOO.util.Dom.get('hidEmlId').value = row.getData('ID');
    YAHOO.util.Dom.get('hidEmlType').value = row.getData('Type');
    YAHOO.util.Dom.get('txtEmlSubject').value = row.getData('Title');

    emailEditor.setEditorHTML(row.getData('Body'));

    //Show the dialog
    dialogs.dlgEmail.show();

}

我读过this文章,但问题似乎并不匹配。 html编辑器的上下文正在填充,然后删除.... sooo,任何帮助都将非常感激。

1 个答案:

答案 0 :(得分:2)

在设置编辑器的html ( row.getData('Body') ),之前,尝试使用html (emailEditor.setEditorHTML(row.getData('Body'));)更新编辑器的支持文本区域。这应该允许它在Chrome / Safari中运行。

相关问题