CKEditor editor1.insertHtml()对我不起作用 [英] CKEditor editor1.insertHtml() not working for me

查看:170
本文介绍了CKEditor editor1.insertHtml()对我不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CKEditor来编辑帖子的评论。我也在使用JQuery。因为每个帖子可能有多个评论,所以我试图将其全部保持基于类。

I am using CKEditor to be able to edit comments to posts. I am also using JQuery. Because there can be multiple comments per post I'm trying to keep it all class based.

以下功能应该隐藏评论的显示区域,插入文本从显示区域进入编辑器,最后显示编辑器。

The following function is supposed to hide the display area of the comment, insert the text form the display area into the editor, and finally display the editor.

function fnCommentControl_edit(divEditBtn){
    divEditBtn = $(divEditBtn);
    var divSaveBtn = divEditBtn.parent().find('.save');
    var divCancelBtn = divEditBtn.parent().find('.cancel');     
    var divEdit = divEditBtn.parent().parent().parent().find('.text').find('.edit');
    var divDisplay = divEditBtn.parent().parent().parent().find('.text').find('.display');  
    var divEditor = divEdit.find('.editor');

    var ckEditor1 = CKEDITOR.replace(divEditor[0],
        {
            toolbar : 'Basic',
            customConfig : '/includes/ckEditorConfig.js'
        });

    ckEditor1.insertHtml('<p>test</p>');

    divEditBtn.hide();
    divSaveBtn.show();
    divCancelBtn.show();
    divEdit.show();
    divDisplay.hide();
}

在我调用该函数后,一切似乎都正常运行,但编辑器没有

After I call the function everything seems to work fine, except the editor has no text in it.

我是使用CKEditor的新手,将不胜感激。

I am new at using CKEditor and would appreciate any assistance.

推荐答案

创建过程不是同步的,因此编辑器在调用它之后还没有完全准备好进行编辑(特别是第一个实例)。

The creation process isn't synchronous, so the editor isn't fully ready to edit (specially the first instance) just after the call to create it.

您应该侦听instanceReady事件以对其进行处理。

You should listen for the instanceReady event to work with it.

这篇关于CKEditor editor1.insertHtml()对我不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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