检查我何时通过单击按钮关闭关闭kendoWindow

时间:2018-04-26 16:09:22

标签: javascript jquery kendo-ui

我有一个kendo窗口,当我点击kendo窗口中的关闭按钮时我需要拿起,但是我无法接收该事件。

我必须以一种特殊的方式来做,我解释一下。

我有一个包含iframe的kendo窗口,而且这个iframe正在根据某些参数进行更改。我需要的是在加载某个iframe时创建一个确认(最后一个iframe完成),当我点击kendo窗口中的关闭按钮时,我只需要能够拿起。

添加代码示例:

 if (!ventanaNombrePantalla.data("kendoWindow")) {
    ventanaNombrePantalla.kendoWindow({
        width: "300px",
        height: "117px",
        title: "Tittle",
        visible: false,
        modal: true,
        actions: ["Maximize", "Close"],
        resizable: false,
        // <%'Descripción: función que se ejecuta cuando se cierra la ventanaNombrePantalla para ocultar el div pantallaJV
        // 'Inputs:
        // 'Outputs:
        // 'DFPJSCADA0700
        // %>
        close: function (e) {
            //if ($("#ventanaNuevaPantalla").)
            $("#divPantallaJV").hide();
            dialogoAbierto = false;
            var url = $("#ventanaNuevaPantalla").attr('src').split("/")[3];//That is a iframe inside the window.

            if(url == "modalBlockLy.asp"){
                e.preventDefault();
                //Here is where i have the problem. I only want this, when the user do click on close.
                //I close the window, with two ways, with the button [X]
                //and invoing ventanaNombrePantalla.close()

            }

            $("#ventanaNuevaPantalla").attr("src", "");

            //this.content($("#body").hide());
        },
        open: function () {
            //this.content($("#body").show());
        }
    }).data("kendoWindow").center();
}

另一种方式:

$(ventanaNombrePantalla.element).closest('.k-window').find('.k-icon.k-i-close').on("click", function (e) {
    //Here, ventanaNombrePantalla.element is null...
    //debugger;
    e.stopPropagation(); // In case you want to 'prevent' the window closing
});

3 个答案:

答案 0 :(得分:0)

您是否尝试过使用窗口事件?

.Events(events => events.Close("myCloseEvent"))

https://demos.telerik.com/aspnet-mvc/window/events

答案 1 :(得分:0)

我可以通过这个选择器实现这一目标:

$(wnd.element).closest('.k-window').find('.k-header .k-window-actions a.k-button').on("click", function(e) {

Demo

检查它是否适合你。

答案 2 :(得分:0)

解决!用那段代码:

$(ventanaNombrePantalla).closest('.k-window').find('.k-icon.k-i-close').closest('a').on("click", function (e) {
        if(!confirm("¿Desea cerrar la ventana?")){
            e.stopPropagation();
            e.preventDefault();
        }
    });
相关问题