Anonymous
Anonymous

Reputation: 1979

Kendo - how to close modal window from view

I have a modal window that displays two text boxes (customer id and customer name). When the user clicks on 'save', I'd like to close the modal window. I tried using $('#NewCustomer').hide() but that doesn't seem to close the window. So how do I close a kendo window from a different function from my ViewModel? Any help would be appreciated.

Thanks!

JS

 var viewModel = kendo.observable({
     ShowNewCustomerForm: function () {
            var newCustomerWindow = $('#NewCustomer').kendoWindow({
                title: "Add New Customer",
                modal: true,
                width: 500,
                height: 300
            }).data("kendoWindow");
            newCustomerWindow.center().open();
            $('#AddNewCustomerBtn').hide();
        },
        SaveCustomer: function (e) {
           // close #NewCustomer here
            $('#NewCustomer').hide();
        }....

Upvotes: 2

Views: 1617

Answers (2)

kashyapa
kashyapa

Reputation: 1626

Kendo Window widget exposes a lot of API. open() & close() methods are available for you to programmatically handle the window.

Here is a demo we have on Kendo Window API methods - http://demos.telerik.com/kendo-ui/window/api

Do take a look at how it has been done in the demo and you can follow the same procedure.

Upvotes: 1

Anonymous
Anonymous

Reputation: 1979

OK -- I was able to figure it out. This is the working code:

    var viewModel = kendo.observable({
         ShowNewCustomerForm: function () {
                var newCustomerWindow = $('#NewCustomer').kendoWindow({
                    title: "Add New Customer",
                    modal: true,
                    width: 500,
                    height: 300
                }).data("kendoWindow");
                newCustomerWindow.center().open();
                $('#AddNewCustomerBtn').hide();
            },
            SaveCustomer: function (e) {
               // close #NewCustomer here
               $("#NewCustomer").closest(".k-window-content").data("kendoWindow").close();        
            }

Upvotes: 1

Related Questions