This is a migrated thread and some comments may be shown as answers.

How to call script based on Data from Model.

1 Answer 18 Views
Window
This is a migrated thread and some comments may be shown as answers.
Greg Gum
Top achievements
Rank 1
Greg Gum asked on 13 Dec 2013, 03:53 AM
I have the following code.  In the model is a property called IsAuthenticated.  After the ajax refresh, I need to check this property, and if true, then close the Window.  What is the best way to do this?

 

@using (Ajax.BeginForm("Login", "Account", new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "loginSection", }))
        {
            @Html.Partial("_LoginInfoPartial", Model)
            <input} type="submit" value="Log in" />
            <button type="button"  id="close_button" onclick="cancelLogin()" >Cancel</button>
             
            <script>
                function cancelLogin()
                {
                    var window = $("#loginWindow").data("kendoWindow");
                    window.close();
                }
            </script>
         }

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Greg Gum
Top achievements
Rank 1
answered on 13 Dec 2013, 03:14 PM
This worked for me to close the window.
Controller:

    return PartialView("_LoginSuccessPartial");

View:

    <script>
    var loginwindow = $("#loginWindow").data("kendoWindow");
    loginwindow.close();
   </script>
Tags
Window
Asked by
Greg Gum
Top achievements
Rank 1
Answers by
Greg Gum
Top achievements
Rank 1
Share this question
or