使用窗口内的自定义关闭按钮关闭 kendoui 窗口 [英] Closing a kendoui window with custom Close button within the window
问题描述
我使用的是 Kendo UI 的窗口组件,它类似于任何模式对话框.
I'm using Kendo UI's window component, which is similar to any modal dialog.
我有一个关闭按钮,如何在单击该按钮时关闭窗口(而不是单击标题栏中的默认x"按钮)
I have a close button in it, how do I close the window upon clicking that button (instead of clicking the default 'x' button in the title bar)
我窗口中的内容是从另一个视图加载的
The content in my window is loaded from another view
@(Html.Kendo().Window()
.Name("window")
.Title("Role")
.Content("loading...")
.LoadContentFrom("Create", "RolesPermissions", Model.Role)
.Modal(true)
.Width(550)
.Height(300)
.Draggable()
.Visible(false)
)
同样的观点,我有
<span id="close" class="btn btn-inverse">Cancel</span>
这是我的主视图(调用窗口的视图)
This is what I have in my main view (the view calling the window)
$(document).ready(function () {
var window = $("#window").data("kendoWindow");
$("#open").click(function (e) {
window.center();
window.open();
});
$("#close").click(function(e) {
window.close();
});
});
推荐答案
基本上你已经知道如何关闭窗口——你需要使用其 API 的 close 方法来完成.
Basically you already know how to close the window - you need to do it with the close method of its API.
$("#window").data("kendoWindow").close();
但是为了将处理程序附加到视图内的按钮,您需要等到内容加载完毕 - 您需要使用 刷新 事件.
But in order to attach the handler to the button inside of the view you need to wait until the content is loaded - you need to use the refresh event.
例如
$('#theWindowId').data().kendoWindow.bind('refresh',function(e){
var win = this;
$('#close').click(function(){
win.close();
})
})
这篇关于使用窗口内的自定义关闭按钮关闭 kendoui 窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!