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

How to refer to a .clone() window

2 Answers 239 Views
Window
This is a migrated thread and some comments may be shown as answers.
jari
Top achievements
Rank 1
jari asked on 20 Mar 2013, 10:26 PM
Hi,

I'm opening Kendo Window using: 
  • var window = $("#window").clone(); 
After opening the window I can't find a way to close it from the window using: 
  •  window.parent.$("#window").data("kendoWindow").close();
If I open the window without .clone() this works fine but then the window content does not refresh always. With .clone() I get following error: 
  • TypeError: 'undefined' is not an object (evaluating 'window.parent.$("#closeThisWindow").data("kendoWindow").close')
I  guess this is because the reference to the cloned object is unknow. I would like to know how to refer to this .clone() window from inside this opened window.

$(document).ready(function() {
    var window = $("#window").clone();
    //var window = $("#window"); --this works
    var onClose = function() {
        $("html, body").css("overflow", "");
    }
    var onOpen = function() {
        $("html, body").css("overflow", "hidden");
    }
    if (!window.data("kendoWindow")) {
        window.kendoWindow({
            actions: ["Custom", "Refresh", "Maximize", "Minimize", "Close"],
            width: 900,
            height: 600,
            iframe: true,
            title: "Report Hours",
            content: "tunnit.free.add.cfm?start="+start+"&end="+end,
            close: onClose,
            open: onOpen,
            modal: true
        });
        window.data("kendoWindow").open();
        window.data("kendoWindow").center();
    } else {
        window.data("kendoWindow").open();
        window.data("kendoWindow").center();
    }
 
});

2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 21 Mar 2013, 11:59 AM
Hi Jari,

Cloned elements are document fragments, which are still not part of the page, unless you append them to the DOM. Document fragments cannot be retrieved later on via selectors, that is why the current scenario does not work. Please always initialize Kendo UI widgets from elements that are part of the page.

Also make sure that you remove any duplicate IDs when cloning elements.

Regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
jari
Top achievements
Rank 1
answered on 21 Mar 2013, 01:28 PM
Thank you for your answer.

I was able to fix this by renaming the clone ID and appending it to the parent DIV (and saving the new clone ID to a var).

BR,

-jari

Tags
Window
Asked by
jari
Top achievements
Rank 1
Answers by
Dimo
Telerik team
jari
Top achievements
Rank 1
Share this question
or