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

Kendo Window undefined

1 Answer 1594 Views
Window
This is a migrated thread and some comments may be shown as answers.
mctl87
Top achievements
Rank 1
mctl87 asked on 13 Oct 2015, 07:29 AM

Hi!
I would like to say that i have already read similiar topics in this forum and none of them solved my problem. When im trying to access dynamically created window data("kendoWindow") the result is undefined :/

So i've got a "Contractors" View which got almost nothing inside it, besides kendo Grid and few buttons + this placeholder:

<div id="editContractorNaturalPersonWindow"></div>

When a user clicks the button, window is opened:

 

$(".contractorNaturalPerson").click(function () {
                var dataUrl = $(this).data("url");
                $("#editContractorNaturalPersonWindow").kendoWindow({
                    content: {
                        title: "title123",
                        url: dataUrl
                    },
                    open: function () {
                        kendoWindow_center("#editContractorNaturalPersonWindow");
                    },
                    refresh: function () {
                        kendoWindow_center("#editContractorNaturalPersonWindow");
                    }
                });
                var dialog = $("#editContractorNaturalPersonWindow").data("kendoWindow");
                dialog.open();
            });

 

Till now everything works, window is being opened, centered, etc. Inside dynamically loaded "EditContractorNaturalPerson" Partial View i've got a simple form with few textboxes and this script:

 

$('.editContractorNaturalPersonForm').submit(function () {
            if ($(this).valid()) {
                $.ajax({
                    url: this.action,
                    type: this.method,
                    data: $(this).serialize(),
                    success: function (data) {
                        if (data.result == "Success") {
                            debugger;
                            var dialog = $("#editContractorNaturalPersonWindow").data("kendoWindow");
                            dialog.close();
                            
                            $('#contractorsGrid').data('kendoGrid').dataSource.read();
                            return false;
                        }
                        else if (data.result == "Error") {
                            debugger;
                            for (prop in data.modelErrors) {
                                if (data.modelErrors[prop].length > 0) {
 
                                    $("#" + prop).next().text(data.modelErrors[prop]);
                                }
                            }
                        }
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert("EditContractorNaturalPerson-AjaxError");
                    }
                });
            }
            return false;
        });

 

This line:

var dialog = $("#editContractorNaturalPersonWindow").data("kendoWindow");

Gives me undefined, EVEN THAT jQuery found this object:

$("#editContractorNaturalPersonWindow")

 I already tried to remove window by destroying this jquery object (k-window) but it breaks its functionality. What can i do ? Please help :)

1 Answer, 1 is accepted

Sort by
-1
Plamen Lazarov
Telerik team
answered on 15 Oct 2015, 07:51 AM

Hi MichaƂ,

I answered this question in the support thread you have opened. Please do not repost issues on multiple support channels, as they waste support resources and delay answers. Thank you for understanding.

Here is the copy-pasted answer, in case somebody else benefits from it:

===

For accessing an existing Window instance from its non-iframe content, I recommend the approach described on the Window's Overview page:

http://docs.telerik.com/kendo-ui/web/window/overview#accessing-an-existing-window-instance-from-its-non-iframe-content

===

Regards,
Plamen Lazarov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Window
Asked by
mctl87
Top achievements
Rank 1
Answers by
Plamen Lazarov
Telerik team
Share this question
or