Kendo Window undefined

2 posts, 0 answers
  1. mctl87
    mctl87 avatar
    2 posts
    Member since:
    Nov 2012

    Posted 13 Oct 2015 Link to this post

    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 :)

  2. Plamen Lazarov
    Admin
    Plamen Lazarov avatar
    135 posts

    Posted 15 Oct 2015 Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top