Kendo UI窗口不会打开具有布局的视图

Kendo UI window will not open a view that has a layout

本文关键字:布局 视图 UI 窗口 Kendo      更新时间:2024-04-14

我正在使用KendoUI进行MVC,试图打开一个Kendo UI窗口来加载其内容,如下所示:

.LoadContentFrom("Edit", "CustomerContact")
.Events(events => events.Open("centerWindow"))

当Edit.cshtml视图使用我的_DialogLayout.chtml时,它将不会加载。当Edit.cshtml视图的Layout=null时,窗口加载得很好。

单击打开对话框时出现的JavaScript错误是:未捕获的类型错误:无法读取未定义的属性"open"

这是我的javascript:.事件(事件=>事件.Open("centerWindow"))

<script>
    $(document).ready(function () {
        $("#btnNewContact")
            .bind("click", function () {
                $("#windowContact").data("kendoWindow").open();
            });
    });
    function centerWindow(e) {
        e.sender.center();
    }
</script>

为什么Edit.cshtml使用_DialogLayout.cshhtml视图时会发生错误,该视图是_Layout.cshtml的精简版本。当我创建一个没有Layout的视图时,它可以完全正常工作。

第二次检查_DialogLayout.cshtml是否包含jQuery(通常在底部)。如果是,您需要删除它。它将替换当前的jQuery版本,因此,您使用.data("kendoWindow")访问的数据缓存为空。