Closing a window on button click

3 Answers 1794 Views
Window
louis
Top achievements
Rank 1
louis asked on 13 Nov 2012, 02:19 AM
If I'm loading the content on my window using LoadContentFrom - which loads the content of another view, how do I close the window if I have a button in that other view with an ID "close"

    $(document).ready(function () {
        var window = $("#window").data("kendoWindow");
 
        $("#open").click(function (e) {
            window.center();
            window.open();
        });
 
        $("#close").click(function (e) {
            window.close();
        });
 
    });

The above java script is within my main view, which doesn't seem to work, presumably because the close button isn't on the same view?

How do I get the window to close by a click of a button in a different view which is rendered in my modal window?

3 Answers, 1 is accepted

Sort by
0
Dave
Top achievements
Rank 1
answered on 14 Nov 2012, 03:20 PM

Hey man, give this a try:

$(#yourbutton).closest(".k-window-content").data("kendoWindow").close();
Of course, replace yourbutton with button name. This will find the closest Kendo window to the button and close it (or whatever else you choose to do with it.)

Hope this helps!
Jay
Top achievements
Rank 1
commented on 15 Jul 2013, 11:17 PM

Dave - your solution worked great in my situation.  Thanks!
0
louis
Top achievements
Rank 1
answered on 14 Nov 2012, 03:22 PM
Got it to work with this

$('#theWindowId').data().kendoWindow.bind('refresh',function(e){
    var win = this;
    $('#close').click(function(){
         win.close();
    })
})

0
Gerry
Top achievements
Rank 1
answered on 09 Sep 2013, 10:55 PM
This is a lot more helpful:

    $(document).ready(function () {
        $('#nameOfYourWindow').data().kendoWindow.bind('refresh', function(e) {
            var win = this;
            $('#btnClose').click(function() {
                win.close();
            });
        });
    });
Tags
Window
Asked by
louis
Top achievements
Rank 1
Answers by
Dave
Top achievements
Rank 1
louis
Top achievements
Rank 1
Gerry
Top achievements
Rank 1
Share this question
or