jquery对话框中的Ckeditor在关闭后不显示

jquery对话框中的Ckeditor在关闭后不显示,ckeditor,Ckeditor,我试图在jQuery对话框中打开ckeditor,当它第一次用ckeditor框打开时,我再次单击它,jQuery对话框将加载textarea而没有编辑器 我假设它是因为我没有正确地销毁它或重新初始化它,我不知道这里有一些我尝试过的片段 <script type="text/javascript"> if (CKEDITOR.instances['ContentText']) { CKEDITOR.remove(CKEDITOR.instances['ContentText']);

我试图在jQuery对话框中打开ckeditor,当它第一次用ckeditor框打开时,我再次单击它,jQuery对话框将加载textarea而没有编辑器

我假设它是因为我没有正确地销毁它或重新初始化它,我不知道这里有一些我尝试过的片段

<script type="text/javascript">
if (CKEDITOR.instances['ContentText']) {
CKEDITOR.remove(CKEDITOR.instances['ContentText']);
}

CKEDITOR.replace('ContentText',
{

disableObjectResizing: true,
resize_enabled: false,
shiftEnterMode: CKEDITOR.ENTER_BR,
toolbarCanCollapse: false,
forcePasteAsPlainText: true
});
</script>

<script type="text/javascript">
if (CKEDITOR.instances.ContentText) {
CKEDITOR.instances.ContentText.destroy();

}

CKEDITOR.replace('ContentText',
{

disableObjectResizing: true,
resize_enabled: false,
shiftEnterMode: CKEDITOR.ENTER_BR,
toolbarCanCollapse: false,
forcePasteAsPlainText: true
});
</script>

if(CKEDITOR.instances['ContentText']){
CKEDITOR.remove(CKEDITOR.instances['ContentText']);
}
CKEDITOR.replace('ContentText',
{
disableObjectResizing:true,
已启用调整大小:false,
移位模式:CKEDITOR.ENTER\u BR,
toolbarCanCollapse:错误,
forcePasteAsPlainText:true
});
if(CKEDITOR.instances.ContentText){
CKEDITOR.instances.ContentText.destroy();
}
CKEDITOR.replace('ContentText',
{
disableObjectResizing:true,
已启用调整大小:false,
移位模式:CKEDITOR.ENTER\u BR,
toolbarCanCollapse:错误,
forcePasteAsPlainText:true
});
这是我在视图中的对话框关闭函数中尝试过的部分视图中表单末尾的代码
试图摧毁。。如果您想查看实际运行的代码,我可以部署它。

可能发生的情况是,您在第二次打开对话框时没有初始化CKeditor。第一次发生在页面加载时。但是第二次模态对话框可能会刷新dom(html)元素,而这些新元素没有附加ckeditor

您可以通过在单击打开对话框时运行初始化代码来解决此问题。最好的方法是在函数中抛出ckeditor代码,并将其添加到触发对话框的click事件中

但是,由于您没有发布打开对话框的代码,我可能会出错。

尝试使用:

CKEDITOR.editor.prototype.destroy
而不是

CKEDITOR.remove
此外,您还应该编写一个在打开包含CKE代码的对话框时调用的函数(销毁和重新实例化实例)

如果这两种方法都不起作用,您可以重命名textarea并使用您创建的新名称调用它:

var newCKname = "ContentText" + Math.floor((Math.random()*50)+1);
$('#ContentText').attr('id',newCKname);
[instantiate CKE again with the newCKname]