0

我正在为 MVC 使用 KendoUI,试图打开一个加载其内容的 Kendo-UI-Window,如下所示:

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

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

单击打开对话框时出现的 JavaScript 错误是:Uncaught TypeError: Cannot read property 'open' of undefined

这是我的javascript: .Events(events => events.Open("centerWindow"))

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

    function centerWindow(e) {
        e.sender.center();
    }
</script>

为什么当 Edit.cshtml 使用 _DialogLayout.cshtml 视图时会发生错误,该视图是 _Layout.cshtml 的精简版。当我创建一个没有布局的视图时,它工作得很好。

4

1 回答 1

0

Check whether _DialogLayout.cshtml includes jQuery a second time (typically at the bottom). If so, you need to remove it. It replaces the current jQuery version, and as a result, the data cache you're accessing with .data("kendoWindow") is empty.

于 2015-02-23T05:50:52.483 回答