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 comme开发者_C百科nt, 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.
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.
精彩评论