Kendo Ui关闭所有打开的对话框

时间:2015-06-24 03:44:39

标签: javascript jquery asp.net-mvc kendo-ui kendo-window

我需要用iframe打开多个kendo窗口。 但是,当我调用close方法时,我发现KendoUI也会关闭所有其他打开的窗口(即使通过调用特定的窗口实例来关闭它)。

我在页面上使用了两种通用方法。

第1页:点击按钮打开第2页,调用customDialog。 第2页:加载时,调用customAlert(“测试123”).....

单击确定....它会关闭两个窗口。

有没有办法阻止这种行为?

不确定是什么问题..但这似乎只发生在点击OK按钮...如果我点击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
});
}

0 个答案:

没有答案