CKEditor editor1.insertHtml() 不适合我
我正在使用 CKEditor 来编辑帖子的评论。我也在使用 JQuery。因为每个帖子可能有多个评论,所以我试图将其全部基于班级。
下面的函数应该隐藏注释的显示区域,将显示区域中的文本插入到编辑器中,最后显示编辑器。
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();
}
在我调用该函数后,一切似乎都工作正常,除了编辑器中没有文本。
我是 CKEditor 的新手,希望得到任何帮助。
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.
I am new at using CKEditor and would appreciate any assistance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建过程不是同步的,因此编辑器在调用创建它之后还没有完全准备好进行编辑(特别是第一个实例)。
您应该监听 instanceReady 事件才能使用它。
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.
You should listen for the instanceReady event to work with it.