Javascript 在.load()之后用类替换CKEditor

Javascript 在.load()之后用类替换CKEditor,javascript,php,jquery,ckeditor,rich-text-editor,Javascript,Php,Jquery,Ckeditor,Rich Text Editor,我正在为我的网站的博客帖子使用CKEditor,但有一个问题,即通过.load()加载所有bog帖子后,它们不再被CKEditor替换 这是通过以下示例完成的: $("#container #postholder").load("http://url.com/viewblog.php?id=155 #container #postholder"); 首先,我对通过.load()方法加载的项调用的脚本有问题。我通过将按钮调用更改为: $(document).on('click','.edity'

我正在为我的网站的博客帖子使用CKEditor,但有一个问题,即通过
.load()
加载所有bog帖子后,它们不再被CKEditor替换

这是通过以下示例完成的:

$("#container #postholder").load("http://url.com/viewblog.php?id=155 #container #postholder");
首先,我对通过
.load()
方法加载的项调用的脚本有问题。我通过将按钮调用更改为:

$(document).on('click','.edity',function(){ });
按钮现在可以工作,但CKEditor不能

假设我在页面上有5个不同的实例,它们都有
ckeditor
的泛型类,所以它们都可以工作

但是,在项目的
.load()
之后,它们不会更改为CKeditor,而是保留文本区域

为了解决这个问题,我在单击“编辑”按钮时尝试了以下方法:

$(document).on('click','.edity',function(){
     CKEDITOR.replace('.ckeditor');
});
这不起作用,然后我尝试使用CKeditor的名称,以便:

$(document).on('click','.edity',function(){
     CKEDITOR.replace('editorName');
});
即使在执行
.load()
之后,这种方法仍然有效,但它只适用于第一个实例。所有其他CKEditor不会更改为CKEditor

我看不出怎么避开这个

有人明白吗

编辑器是这样创建的:

这是每个博客文章结果的foreach循环。ckEID变量是posts ID+1

<div class="editor">
<textarea name="muffin" id="'.$ckEID.'" class="ckeditor">'.$text.'</textarea>
</div>
单击“编辑”按钮时转换文本区域的步骤

刚刚尝试使用replaceAll,错误控制台显示,例如

uncaught exception: The editor instance "message" is already attached to the provided element.

我在页面上还有其他文本区域,在使用replaceAll时似乎一切都乱七八糟。

我知道,除非文本区域分配了
id
,否则ckeditor将无法工作。我的ckeditor是通过PHP foreach动态创建的。我为每个文本区域生成一个唯一的ID。好的,我可能错了,但我认为您需要在
replace
函数中使用该ID。不过,这可能与你的主要问题无关。我已经尝试过了。仅在使用文本区域名称时才起作用,并且仅在第一次使用时才起作用。替代品也不起作用。感谢您的尝试:)请在您的问题中显示呈现的HTML,而不是PHP。
uncaught exception: The editor instance "message" is already attached to the provided element.