admin管理员组

文章数量:1334935

According to this page, all I have to do is call the following code from the content of the window since I am not using iframe:

$(buttonInsideWindow).closest(".k-window-content").data("kendoWindow").close();

It doesn't work. When I try to close this manually from the console, it returns a null when you try to retrieve the kendoWindow. (That is, it returns the correct div when $(buttonInsideWindow).closest(".k-window-content") is invoked but the .data("kendoWindow") on it returns null).

I am using a custom button inside the window content which calls the close event manually. This is how I invoke the window in the first place:

function otherCusLogInWindow_Open() 
{
    var otherCusLogInWindow = $("#otherCusLogInWindow");

    otherCusLogInWindow.kendoWindow({
        width: "535px",
        height: "850px",
        title: "ASDF",
        modal: true,
        actions: ["Minimize", "Maximize", "Close"],
        content: "otherCusLogIn.jsp",
        iframe: false,
        visible: false,
        draggable: true,
        resizable: true

    }).data("kendoWindow").center().open();
}

And inside the window content, close event is trivial:

function closeWindow(parentFuncCall) {
    $("#otherCusLogInWindow").closest(".k-window-content").data("kendoWindow").close();
}

Just to get this out of the way, I am not able to use iframe for other reasons. I need to get this to work in its current state.

How can I solve the issue?

According to this page, all I have to do is call the following code from the content of the window since I am not using iframe:

$(buttonInsideWindow).closest(".k-window-content").data("kendoWindow").close();

It doesn't work. When I try to close this manually from the console, it returns a null when you try to retrieve the kendoWindow. (That is, it returns the correct div when $(buttonInsideWindow).closest(".k-window-content") is invoked but the .data("kendoWindow") on it returns null).

I am using a custom button inside the window content which calls the close event manually. This is how I invoke the window in the first place:

function otherCusLogInWindow_Open() 
{
    var otherCusLogInWindow = $("#otherCusLogInWindow");

    otherCusLogInWindow.kendoWindow({
        width: "535px",
        height: "850px",
        title: "ASDF",
        modal: true,
        actions: ["Minimize", "Maximize", "Close"],
        content: "otherCusLogIn.jsp",
        iframe: false,
        visible: false,
        draggable: true,
        resizable: true

    }).data("kendoWindow").center().open();
}

And inside the window content, close event is trivial:

function closeWindow(parentFuncCall) {
    $("#otherCusLogInWindow").closest(".k-window-content").data("kendoWindow").close();
}

Just to get this out of the way, I am not able to use iframe for other reasons. I need to get this to work in its current state.

How can I solve the issue?

Share Improve this question edited Nov 20, 2014 at 13:53 Brian Mains 50.7k35 gold badges155 silver badges260 bronze badges asked Mar 28, 2013 at 7:00 TtT23TtT23 7,05035 gold badges105 silver badges177 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 2

Try this:

$("#otherCusLogInWindow").data("kendoWindow").close();

Here is the documentation about getting the client-side object reference: http://docs.kendoui./getting-started/web/window/overview#accessing-an-existing-window

When your content page returned a view, not a partial view, then maybe get this problem, because your content page has a new reference of jquery.js. So the jquery data method didn't work.

window.parent.$("#otherCusLogInWindow").data("kendoWindow").close() 

One thing to be aware of is that if you can close the window when it is an iframe but the window reference is null otherwise, you are probably importing an additional jquery reference. The second jquery reference will have a different scope that the first where the Kendo window was created.

本文标签: javascriptUnable to close window from its content in Kendo WindowStack Overflow