猿问

数据在编辑时不具有约束力

我正在尝试为博客实现 CKEditor。我的创建博客工作正常,但由于某种原因,编辑博客页面不显示已存在的内容。


如果我删除 CKEditor.replace 脚本,则正常的 EditorFor 显示正常。请参阅下面的图片。


我读过很多帖子以及 CKEditor 文档,我所做的应该是正确的。


有没有技巧可以让预先存在的数据显示在 CKEDITOR 内容区域中?


这是添加CKEDITOR的JS


<script>CKEDITOR.replace("MainContent")</script>

这是 HTML。


<div class="col-md-10">

@Html.EditorFor(model => model.Content, 

   new { htmlAttributes = 

          new { @id = "MainContent", @class = "form-control" } })

</div>

当使用 CKEDITOR.replace 时,它看起来像这样......内容区域中没有显示数据。

当CKEDITOR.replace被删除后,看起来像这样,内容显示正确

http://img.mukewang.com/64aa1bb00001ce6303210392.jpg


喵喔喔
浏览 91回答 1
1回答

不负相思意

好吧,我不知道为什么它不能像描述的那样开箱即用,但我添加了一些 JavaScript,现在它可以工作了。我仍然希望了解为什么它不能按描述工作。&nbsp; &nbsp; &nbsp; &nbsp; $.ajax({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url: 'Blog/Edit',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type: 'POST',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data: JSON.stringify(Blog),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contentType: 'application/json;charset=utf-8',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; success: function (data) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (data.success == true) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; window.location.href = "../Blog";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (data.success == false) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alert("Error occured..!!")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error: function () {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alert("Error occured..!!");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; });
随时随地看视频慕课网APP
我要回答