我需要用 iframe 打开多个剑道窗口。但是,当我调用 close 方法时,我发现 KendoUI 也会关闭所有其他打开的窗口(即使通过调用特定的窗口实例来关闭它)。
我在页面上使用了两种通用方法。
第 1 页:单击按钮通过调用 customDialog 打开第 2 页。第 2 页:加载时,调用 customAlert("testing 123").....
单击确定....它会关闭两个窗口。
有没有办法可以防止这种行为?
不知道是什么问题..但这似乎只发生在单击确定按钮...如果我单击 X 按钮或 Esc .. 它似乎工作正常!
提前致谢。
//custom Dialog used to open page views inside an iframe
//pageUrl: relativeUrl as in /myPage/index
//window title: Text that needs to be displayed on top of Dialog. default is "Information"
//$statusTracker : an element on parent page that can be used to pass outcome. sets it to '' when closed using the dialog X button.
//onCloseFunc: Parameterless callback function invoked on close
//onOpenFunc: Parameterless callback function invoked on opening dialog
function customDialog(pageUrl, windowTitle, $statusTracker, onCloseFunc, onOpenFunc) {
var instanceId = new Date().getTime();
if ($statusTracker != null) {
$statusTracker.val('');//reset associated status
$statusTracker.data('win-id', 'dialog' + instanceId);
}
$('body').append('<div id="dialog' + instanceId + '" />');
var $window = $("#dialog"+ instanceId),
undo = $("#undoDialog" + instanceId)
.bind("click", function () {
$window.data("kendoWindow").open();
undo.hide();
});
var onClose = function () {
undo.show();
setTimeout(function () {
if (typeof onCloseFunc == "function") {
onCloseFunc();
}
}, 500);
};
var onOpen = function () {
$window.css('overflow', 'hidden');
if (typeof onOpenFunc == "function") {
setTimeout(function () { onOpenFunc(); }, 500);
}
};
$window.kendoWindow({
iframe: true,
draggable: false,
modal: true,
resizable: false,
width: "80%",
height: "80%",
position: {
top: "10%",
left: "10%"
},
deactivate: function () {
this.destroy();
},
autoFocus: true,
actions: [
"Maximize",
"Close"
],
title: windowTitle || 'Window',
content: pageUrl,
open: onOpen,
close: onClose
});
}
//shows an alert dialog
function customAlert(message, okFunction) {
var instanceId = new Date().getTime();
$('body').append('<div id="cc2' + instanceId + '"><table style="width:100%;height:100%"><tr><td colspan="3" style="padding-bottom:10px"><span class="alert-content">' + (message || '') + '</span></td></tr>' + '<tr><td style="width"40%"></td><td style="width:20%"><a href="#" class="btn-ok">Ok</a></td><td></td></tr></table></div>');
var $window = $("#cc2" + instanceId),
undo = $("#undo2" + instanceId)
.bind("click", function () {
$window.data("kendoWindow").open();
undo.hide();
});
var onClose = function () {
undo.show();
if (typeof (okFunction) == 'function') {
setTimeout(okFunction, 50);
}
}
var onOpen = function () {
$window.find('.btn-ok').bind('click', function () {
$window.data("kendoWindow").close();
});
$window.css('overflow', 'hidden');
$window.find('.alert-content').html(message || '');
}
$window.kendoWindow({
modal: true,
deactivate: function () {
this.destroy();
},
autoFocus: true,
actions: [
"Close"
],
title: 'Alert',
close: onClose,
open: onOpen
});
}