0

我有一个非常奇怪的错误。我在 MVC 上有一个页面,它显示两个编辑器,并传递了一个包含两个编辑器值的模型。模型如下:

public class BulletinsModel
    {
        [AllowHtml]
        [Display(Name = "Some Bulletin")]
        public string SomeBulletin { get; set; }

        [AllowHtml]
        [Display(Name = "Other Bulletin")]
        public string OtherBulletin { get; set; }
    }

然后,我定义了一个视图,它接收这个视图模型并将其映射到两个剑道编辑器。还有一些 javascript 代码来发布更新信息。

@model BulletinsModel

<div id="settings">
    <div class="form-horizontal">
        <div class="form-group">
            @Html.LabelFor(m => m.SomeBulletin, new { @class = "col-md-6 text-left" })
            @(Html.Kendo().EditorFor(m => m.SomeBulletin).Encode(false).Name("Some_Bulletin"))

            @Html.LabelFor(m => m.OtherBulletin, new { @class = "col-md-6 text-left" })
            @(Html.Kendo().EditorFor(m => m.OtherBulletin).Encode(false).Name("Other_Bulletin"))
        </div>      
    </div>
</div>

我呈现此视图的操作方法的代码如下(没什么花哨的):

[HttpGet]
public PartialViewResult Index()
{
    ViewBag.ActiveSectionName = "Bulletins";
    var bulletinModel = GetBulletinsModel();
    return PartialView("_Bulletins",bulletinModel);          
}

但是,我的问题是,在多次点击索引操作后,编辑器变得没有响应,我无法编辑它们的信息。这只发生在 IE 上,因为我无法在其他浏览器中复制该问题。

编辑:我刚刚注意到编辑器被冻结了。为了能够编辑编辑器内部的内容,我需要单击工具栏的任何选项以使其再次响应。这是为什么?

4

1 回答 1

0

事实证明,这个问题正在发生在 IE 上,详见这篇文章: 添加、删除、添加编辑器 -> 页面上的所有编辑器在 IE 中变为只读。问题在于编辑器中的 iframe。我正在使用 Ajax 请求加载我的页面,在发出请求以使其工作之前,我必须向该请求添加以下代码。

    function unloadEditor($editor) {
        if ($editor.length > 0) {
            $editor.data('kendoEditor').wrapper.find("iframe").remove();
            $editor.data('kendoEditor').destroy();
        }
    }
    unloadEditor($('#myEditor'));
于 2016-06-17T16:13:05.513 回答