【发布时间】:2016-03-11 17:25:16
【问题描述】:
这是我目前实现的代码
<div class="CommentBox" style="display: none;">
<div class="editor-field">
@Html.TextAreaFor(model => model.ObjComment.Description, new { @id = "txtComment", @class = "clsCKEditor" })
</div>
</div>
而JQuery代码如下:
$("#btnComment").click(function () {
var editor = CKEDITOR.instances[txtComment];
if (CKEDITOR) {
if (CKEDITOR.instances.txtComment) {
CKEDITOR.instances.txtComment.destroy();
}
}
$("#txtComment").val('');
CKEDITOR.replace('txtComment', { uiColor: '#D8D8D8' });
CKEDITOR.config.htmlEncodeOutput = true;
$(".CommentBox").show("slow");
});
在这里,txtComment 是我用作编辑器的文本区域的 id。单击该按钮,将生成编辑器,并显示包含该编辑器的 div。
这在 Chrome 和 Firefox 中运行良好。但是,它在 IE11 中的这一行给出了错误:
var editor = CKEDITOR.instances[txtComment];**'txtComment' is undefined**
阿米错过了什么?请你帮我解决这个问题。提前致谢。
【问题讨论】:
标签: jquery asp.net asp.net-mvc-3 ckeditor