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

Contents of previous windows are displayed on opening window for second time

3 Answers 1367 Views
Window
This is a migrated thread and some comments may be shown as answers.
Santosh
Top achievements
Rank 1
Santosh asked on 30 May 2013, 05:59 AM
I have a kendo window and button in my asp.net mvc 3 application view.

@(Html.Kendo().Window()
                  .Name("TestWindow")
                  .Width(420)
                  .Height(70)
                  .Draggable()
                  .Modal(true)
                  .HtmlAttributes(new { @class = "TestWindow" })
                  .Resizable()
                  .Title("Window1 ")
                  .Content(@<text>@Html.Partial("_PartialWindow", Model.Prop1) </text>)
                )

on click of a button I am opening the above declared window using below javascript code.

var windowobj = window.data("kendoWindow");
           windowobj.open();
           windowobj.center();
hen in the window i enter value in the textbox. the opened window has Ok button, on click of that button, we use java-script code.

windowobj.close();

Now again clicking on parent button I open the window and expect that the text box in window will have no values. but it retains those values. Is there a function like refresh which will clear the previous contents.

Thanks,
Santosh

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 30 May 2013, 11:51 AM
Hi Santosh,

Yes, there is a refresh method:

http://docs.kendoui.com/api/web/window#methods-refresh

The method can also be called without parameters. In this case the initial configuration options are used.

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Santosh
Top achievements
Rank 1
answered on 14 Jun 2013, 07:12 AM
Even calling the refresh method gives me the text which was entered for the first time. below is sample code.
<script id="kwindowWindow" type="text/x-kendo-template">
    <label id="lblkwindow">kwindow</label>
    <input class="text-box single-line password kwindow-text" id="txtkwindow" type="password"/>
    <br/>
    <br/>
    <input id="btnOk" class="kwindow-confirm"  type="button" value="OK" />
    <input id="btnCancel" class="kwindow-cancel"  type="button" value="Cancel" />
    <br/>
</script>
 
  var kendoWindow = $("<div />").kendoWindow({
                resizable: false,
                modal: true
            });
          
            windowobj = kendoWindow.data("kendoWindow")
                .content($("#kwindowWindow").html())
                .center().open();
            windowobj.refresh();
             
            var row = grid.tbody.find(":checked:first");
            var selectedSpeIp = $(row).parents('tr').find('td:eq(2)').html();
            var selectedSpeName = $(row).parents('tr').find('td:eq(1)').html();
                       
            kendoWindow
                .find(".kwindow-confirm,.kwindow-cancel,.kwindow-text")
                .click(function () {
                    if ($(this).hasClass("kwindow-confirm")) {
                        var kwindow = $(".kwindow-text").val();
                        alert(kwindow);
                        // here previously entered text is shown
                    }
                    if ($(this).hasClass("kwindow-cancel")) {
                        windowobj.close();
                    }
                })
                .end();
0
Dimo
Telerik team
answered on 17 Jun 2013, 08:53 AM
Hello Santosh,

The Window refresh() method works in three cases:

1. When the Window displays an iframe with a set URL
2. When the Window displays a partial view with a set URL
3. When the Window displays a content template

The scenario that you have provided in the code snippet does not match any of the above cases, because the Window content is inserted manually. Please modify your implementation, or alternatively, replace the Window content manually on every opening.

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Window
Asked by
Santosh
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Santosh
Top achievements
Rank 1
Share this question
or