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

How do I return a value from a Window form field?

1 Answer 627 Views
Window
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 10 May 2019, 01:27 PM

I want to show a Kendo window, type something in a textbox in the window, and return the value from to the parent page. How can I do this?

My window definition.

<kendo-window name="InstallerSearch"
              title="Search for Installer"
              draggable="true"
              resizable="true"
              width="1100"
              height="550"
              modal="true"
              visible="false"
              on-close="onClose"
              actions="actions"
              iframe="true">
    <content>
        loading...
    </content>
    <popup-animation enabled="true" />
</kendo-window>

 

JavaScript to open window

function selectInstaller() {
    var window = $("#InstallerSearch").data("kendoWindow");
    window.refresh({
        url: "@Url.Content("/Admin/Installers/Search/")"
    });
    window.open();
    window.center();
}

 

Razor page content for the window

Installer Name<br />
<input name="InstallerName" id="InstallerName" type="text" class="form-control-md" />

 

JavaScript for the close where I want to get the value in the textbox in the window but user input is undefined.

function onClose() {
    var userinput = $("#InstallerName").val();
    alert(userinput);
}

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Ianko
Telerik team
answered on 14 May 2019, 11:55 AM
Hello John,

As you are using an iframe, you should get the iframe first and get its contentWindow in order to access the DOM of the page loaded in that iframe:

function onClose(ev) {
    var iframe = ev.sender.element.find("iframe").get(0);
    var userinput = iframe.contentWindow.$("#InstallerName").val();
    alert(userinput);
}


Regards,
Ianko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Window
Asked by
John
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Share this question
or