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

Window is not centered the first time opened

2 Answers 614 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 23 Feb 2012, 02:37 AM

Hello all, Using the below code, I open, (and reopen) a window.  I cannot get the first instance to be centered.

$(".jobLocationLink").live('click', function () {
        currentJobId = $(this).data("id");
        var parentGrid = $(this).data("parentGrid");
        var title = $(this).attr("title");
        var href = "../ModalWindows/JobLocationNotes.aspx?jobId=" + currentJobId;
        var myWin = $("#jobLocationWindow")
 
        if (!myWin.data("kendoWindow")) {
            // window not yet initialized
            myWin.kendoWindow({
                content: href,
                center: true,
                title: "Job Location History",
                iframe: true,
                width: "800px",
                height: "400px",
                scrollable: false
            });
        }
        else {
            // reopening window
            myWin.data("kendoWindow")
                .refresh(href) // request the URL via AJAX
                .open() // open the window
                .center();
        }
 
    });


Thanks!

2 Answers, 1 is accepted

Sort by
-1
Accepted
Alex Gyoshev
Telerik team
answered on 23 Feb 2012, 08:47 AM
Hello Jeremy,

There is no configuration option that centers the window. You should center it manually, like this:

        if (!myWin.data("kendoWindow")) {
            // window not yet initialized
            myWin.kendoWindow({
                content: href,
                title: "Job Location History",
                iframe: true,
                width: "800px",
                height: "400px",
                scrollable: false,
                visible: false
            }).data("kendoWidnow").center().open();

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
Jeremy
Top achievements
Rank 1
answered on 23 Feb 2012, 06:18 PM
Alex, please fix the typo in your solution:

.data("kendoWidnow") 

I copied it and was thoroughly confused why I was getting ".center" is not a function.  Sp please edit it before the next guy copies this function verbatim.

and thanks again!

Tags
Window
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Jeremy
Top achievements
Rank 1
Share this question
or