未捕获[CKEDITOR.editor]实例;html";已经存在
我在加载CKEDITOR时遇到问题。我做了这里描述的一切:但无论如何,我得到了一个错误(Google Chrome 4.x)未捕获[CKEDITOR.editor]实例“html”已经存在。 这是我的密码:未捕获[CKEDITOR.editor]实例;html";已经存在,ckeditor,Ckeditor,我在加载CKEDITOR时遇到问题。我做了这里描述的一切:但无论如何,我得到了一个错误(Google Chrome 4.x)未捕获[CKEDITOR.editor]实例“html”已经存在。 这是我的密码: <script type="text/javascript" src="/engine/jq.js"></script> <script type="text/javascript" src="/engine/cke/ckeditor.js"></
<script type="text/javascript" src="/engine/jq.js"></script>
<script type="text/javascript" src="/engine/cke/ckeditor.js"></script>
<script type="text/javascript" src="/engine/cke/adapters/jquery.js"></script>
<textarea class="jquery_ckeditor" name="html" id="html" rows="10">text</textarea>
<script type="text/javascript">
if (CKEDITOR.instances['html']) { CKEDITOR.remove(CKEDITOR.instances['html']); // with or without this line of code - rise an error }
CKEDITOR.replace('html');
</script>
文本
if(CKEDITOR.instances['html']){CKEDITOR.remove(CKEDITOR.instances['html']);//有或没有这行代码-引发错误}
CKEDITOR.replace('html');
相同的错误,但是使用jQuery适配器获得它。检查textarea的类。据我所知,类为“ckeditor”的所有文本区域都会自动转换为编辑器。因此,不要麻烦用javascript设置它,也不要更改类。检查以下内容:
if(CKEDITOR.instances['html']){
删除CKEDITOR.instances['html']
};
CKEDITOR.replace('html');
您的页面有html容器,是否尝试重命名您的文本区域
<textarea class="jquery_ckeditor" name="editor" id="editor" rows="10">text</textarea>
<script type="text/javascript">
CKEDITOR.replace('editor');
</script>
文本
CKEDITOR.replace('editor');
删除class='ckeditor'
,因为它会触发自动更换系统。如果使用jQuery,则有一个修复程序
//从页面中删除编辑器
$('textarea').ckeditor(函数(){
这个。销毁();
}); 使用jquery ckeditor适配器-我能够使用此函数重新初始化ajax内容中的ckeditor textarea
function initCKEditor() {
$('.wysiwyg').ckeditor(function(e){
delete CKEDITOR.instances[$(e).attr('name')];
},{
toolbar:
[
['Bold','Italic','Underline','Strike','-','NumberedList','BulletedList','-','Paste','PasteFromWord','-','Outdent','Indent','-','Link','-','Maximize','-','Source']
],
skin: 'office2003'
}
);
}
适合我的解决方案:在Ajax视图中,有两个控件
@Html.TextAreaFor(model => model.offreJob.profile, new { @class = "input_text_area_nofloat", @style = "width:590px", @id = "ck_profile" })
及
我使用以下脚本:
<script>
if (CKEDITOR.instances['ck_profile']) {
delete CKEDITOR.instances['ck_profile'];
}
CKEDITOR.replace('ck_profile');
if (CKEDITOR.instances['ck_description']) {
delete CKEDITOR.instances['ck_description'];
}
CKEDITOR.replace('ck_description');
</script>
if(CKEDITOR.instances['ck_profile']){
删除CKEDITOR.instances['ck_profile'];
}
CKEDITOR.replace('ck_profile');
if(CKEDITOR.instances['ck_description']){
删除CKEDITOR.instances['ck_description'];
}
CKEDITOR.replace('ck_description');
试试这个,希望它管用,它对我管用
for(CKEDITOR.instances['html'中的html)
{
CKEDITOR.instances[html].destroy()
}
试试这个,它对我有用
是的,好吧。我也有同样的问题。正如我所看到的,没有答案。这不是在创建它之后立即将其从页面中删除吗?会有什么效果?它会有什么帮助?天哪,这对我来说很有效。我想它只是在类为
ckeditor
的元素上加载ckeditor,而您尝试加载编辑器将被称为second尝试并将失败。如果您将$(选择器).ckeditor()
包装在try/catch中,就像try{$(选择器).ckeditor();}catch(err){console.log(err);}
,那么它将在控制台中以错误开始,您将看到它已经加载了默认的ckeditor,并说它无法创建新实例。
<script>
if (CKEDITOR.instances['ck_profile']) {
delete CKEDITOR.instances['ck_profile'];
}
CKEDITOR.replace('ck_profile');
if (CKEDITOR.instances['ck_description']) {
delete CKEDITOR.instances['ck_description'];
}
CKEDITOR.replace('ck_description');
</script>
var editor = CKEDITOR.instances["your_textarea"];
if (editor) { editor.destroy(true); }