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

Windows attributes are not refreshing

3 Answers 85 Views
Window
This is a migrated thread and some comments may be shown as answers.
HIMADRI
Top achievements
Rank 1
HIMADRI asked on 13 Aug 2012, 09:05 PM
I have the following code.

$(

'span[data-class=ModalLink]').click(openmodal);
$('a[data-class=ModalLink]').click(openmodal);

    $('span[data-class=ModalLink]').click(openmodal);
    $('a[data-class=ModalLink]').click(openmodal);
    function openmodal(event) {
        event.preventDefault();
        var contentUrl = $(this).attr("data-content");
        if (!contentUrl) {
            contentUrl = $(this).attr("href");
        }
        if (contentUrl) {
            var dialog = $("#modalwindow");
            dialog.kendoWindow({
                modal: true,
                title: $(this).attr("data-title"),
                actions: ["Close"],
                draggable: $(this).attr("data-draggable"),
                resizable: $(this).attr("data-resizable"),
                height: $(this).attr("data-height"),
                width: $(this).attr("data-width"),
                content: contentUrl
            });
            dialog.data("kendoWindow").center();
            dialog.data("kendoWindow").open();
        }
        else {
            alert("The URL to populate the modal window is missing.");
        }
I want the window configuration value like width, height etc. to change every time I open the window. It is not happening. I can see in the debugger that new values are there window is not updating the values except content. How can do this?
 

3 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 14 Aug 2012, 09:26 AM
Hello Himadri,

The window should be initialized just once. You can simply destroy the window when it is closed, so that it gets initialized every time:

    dialog.clone().appendTo("body").kendoWindow({
        deactivate: function(e) {
            this.destroy();
        }
    }); 


Kind regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
HIMADRI
Top achievements
Rank 1
answered on 14 Aug 2012, 01:43 PM
Alex,
Thanks for the reply. I tried to add the deactivate event on the initalization like below. It did destroy the window but next time when openmodal called it is skippng the initialization and trying to execute dialog.data("kendowWindow").center(). This results in error because kendoWindow is already destroyed. I tried your code too but that is opening more than one window. Thanks for the help.

        var ondeactivate = function (e) {
            this.destroy();
        }
    $('span[data-class=ModalLink]').click(openmodal);
    $('a[data-class=ModalLink]').click(openmodal);
    function openmodal(event) {
        event.preventDefault();
        var contentUrl = $(this).attr("data-content");
        if (!contentUrl) {
            contentUrl = $(this).attr("href");
        }
        if (contentUrl) {
            var dialog = $("#modalwindow");
            dialog.kendoWindow({
                deactivate: ondeactivate,
                modal: true,
                title: $(this).attr("data-title"),
                actions: ["Close"],
                draggable: $(this).attr("data-draggable"),
                resizable: $(this).attr("data-resizable"),
                height: $(this).attr("data-height"),
                width: $(this).attr("data-width"),
                content: contentUrl
            });
            dialog.data("kendoWindow").center();
            dialog.data("kendoWindow").open();
        }
        else {
            alert("The URL to populate the modal window is missing.");
        }
    }
0
Alex Gyoshev
Telerik team
answered on 14 Aug 2012, 01:50 PM
Hello Himadri,

In the code snippet I posted earlier, I was cloning the source element and appending it to the body:

    dialog.clone().appendTo("body").kendoWindow({ ...

This allows the window to be initialized each time.

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