Closing a window on button click

5 posts, 0 answers
  1. louis
    louis avatar
    16 posts
    Member since:
    Nov 2011

    Posted 12 Nov 2012 Link to this post

    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?
  2. Dave
    Dave avatar
    35 posts
    Member since:
    Oct 2012

    Posted 14 Nov 2012 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. louis
    louis avatar
    16 posts
    Member since:
    Nov 2011

    Posted 14 Nov 2012 Link to this post

    Got it to work with this

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

  5. Jay
    Jay avatar
    1 posts
    Member since:
    Feb 2011

    Posted 15 Jul 2013 Link to this post

    Dave - your solution worked great in my situation.  Thanks!
  6. Gerry
    Gerry avatar
    7 posts
    Member since:
    Sep 2012

    Posted 09 Sep 2013 Link to this post

    This is a lot more helpful:

        $(document).ready(function () {
            $('#nameOfYourWindow').data().kendoWindow.bind('refresh', function(e) {
                var win = this;
                $('#btnClose').click(function() {
                    win.close();
                });
            });
        });
Back to Top
UI for ASP.NET MVC is VS 2017 Ready