CKEditor的多个实例(在Safari中)

我在JQuery UI对话框中创建CKEditor的多个实例时遇到问题。 该对话框通过AJAX加载远程表单,因此目标是能够关闭并重新打开对话框并拥有编辑器的新实例。 使用默认选项时,重新打开对话框时会出现错误,指出已存在具有该名称的编辑器。 所以我尝试了几种破坏编辑器实例的方法,它们都导致了同样的问题。 重新加载编辑器时,文本区域显示为null,按钮不起作用。

目前我正在使用这种破坏实例的方法:

var instance = CKEDITOR.instances['test']; if (instance) { CKEDITOR.remove(CKEDITOR.instances['test']); } 

我在这里可以下载几个简单的html文件重新创建了这个问题。

编辑:我只是尝试使用两个远程文件与文本区域具有不同的名称,我有同样的问题。 当一个对话框打开然后关闭时,另一个对话框在打开时有一个“null”CKEditor。

此外,显然这只是Safari中的一个问题。

这就是我所做的:

 var CKeditors = {}; function loadEditors() { var $editors = $("textarea.ckeditor"); if ($editors.length) { $editors.each(function() { var editorID = $(this).attr("id"); if(CKeditors[editorID]){ CKeditors[editorID].destroy(); CKeditors[editorID] = null; } var dst = editorID+'-element'; var html = ''; if( $(this).val() ){ html = $(this).val(); } CKeditors[editorID] = CKEDITOR.appendTo(dst, {}, html); }); $("textarea.ckeditor").hide(); } } function updateCKEditors() { for(x in CKeditors){ $("#"+x).val(CKeditors[x].getData()); } } 

在ajax成功后我做了

 loadEditors() 

在表单提交之前(例如使用ajax):

 updateCKEditors() 

你需要jQuery让它工作。 这适用于zend_forms,但经过一些修正后也应该以正常forms工作。 与’dst’一起玩这样做。

有点老话题,但我遇到了类似的问题。

我上面使用了activ的解决方案,效果很好! CKEDITOR.appendTo对我loadEditors ,但是对于loadEditors函数的下一个小修改它做了:

 function loadEditors() { var $editors = $("textarea.ckeditor"); if ($editors.length) { $editors.each(function() { var editorID = $(this).attr("id"); if(CKeditors[editorID]){ CKeditors[editorID].destroy(); CKeditors[editorID] = null; } var dst = editorID+'-element'; CKeditors[editorID] = CKEDITOR.replace(dst, {}); }); } } 

我所做的:

 var instance = CKEDITOR.instances['test']; instance.destroy(); instance = null;