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

[Solved] open a centered window

14 Answers 598 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
nachid
Top achievements
Rank 1
nachid asked on 23 Jul 2010, 04:24 PM
I am struggling for a while and whatever I did I could not have a window opened in the center
Any help or example would be appreciated

var windowElement= $.telerik.window.create(
{
    title            : "Success",
    html           : "<strong>this is a test...</strong>",
    modal       : true,
    resizable  : false,
    draggable: true,
    visible       : false,
    width         :300,
    height       :100
}
});
windowElement.center();

regards
Nachid

14 Answers, 1 is accepted

Sort by
0
Accepted
Alex Gyoshev
Telerik team
answered on 26 Jul 2010, 11:41 AM
Hi Nachid,

The $t.window.create function returns the window' DOM object, not the client-side object -- so calling the center() method should happen through the data('tWindow') object. Furthermore, because your window is modal, the open() method should center it automatically. Therefore, the following code should do what you want:

var dialog = $.telerik.window.create({
        title     : "Success",
        html      : "<strong>this is a test...</strong>",
        modal     : true,
        resizable : false,
        draggable : true,
        visible   : false,
        width     : 300,
        height    : 100
    })
    .data('tWindow').open();

Sincerely yours,
Alex Gyoshev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alex
Top achievements
Rank 1
answered on 03 Sep 2010, 06:47 PM
Alex, I don't know if is just me, but I've updated the libraries to 2010.2.825 and now the modal windows are not centered by default, do I have to do something else so the window came up centered???

Thanks!!!
0
Mark Dawson
Top achievements
Rank 1
answered on 04 Sep 2010, 02:35 PM
I've also got this problem.
0
nachid
Top achievements
Rank 1
answered on 04 Sep 2010, 08:46 PM
That's not the case for me and I am usign 2010.2.825
I still have to call explicitly the center() method
0
Joan Vilariño
Top achievements
Rank 2
answered on 07 Sep 2010, 11:59 AM
I have the same problem... my window is modal and doesn't get centered...

Same 2010.2.825 version...

Any suggestion?

Thanks!
0
Joan Vilariño
Top achievements
Rank 2
answered on 07 Sep 2010, 01:27 PM
By browsing this forum I found the solution:

var w = $('#myWindow').data('tWindow');
w.center().open();

This works pretty cool

Thanks!!
0
Alex
Top achievements
Rank 1
answered on 07 Sep 2010, 05:20 PM
Thank you very much Joan!!! :)
0
Won
Top achievements
Rank 1
answered on 16 Sep 2010, 08:30 PM
Where does this code go?

var w = $('#myWindow').data('tWindow');
w.center().open();
0
Joan Vilariño
Top achievements
Rank 2
answered on 17 Sep 2010, 08:03 AM
That should go in your javascript function to open the window.
0
Adam Gritt
Top achievements
Rank 1
answered on 24 Sep 2010, 04:30 PM
I don't know if anyone else has noticed this or not, but I find that when using the following bit of javascript on a page that doesn't already have a window on it, it will fail due to setting the "draggable" property to true.  If I set it to false everything works fine.  Has anyone noticed this issue at all or can confirm it?  I am using the latest release (2010.2 825) and Chrome 6.  I came across this issue in trying to answer another forum post and am just looking for confirmation.  This is the error that I get in Chrome:   Uncaught TypeError: Cannot read property 'windowMove' of undefined telerik.window.js:131

var dialog = $.telerik.window.create({
        title     : "Success",
        html      : "<strong>this is a test...</strong>",
        modal     : true,
        resizable : false,
        draggable : true,
        visible   : false,
        width     : 300,
        height    : 100
    })
    .data('tWindow').open();
0
nachid
Top achievements
Rank 1
answered on 26 Sep 2010, 11:13 AM
It is more likely that the file /telerik.draganddrop.min.js is not there
0
Adam Gritt
Top achievements
Rank 1
answered on 27 Sep 2010, 03:06 PM
Thanks nachid, I thought I had that file included but it was missing.  However, interestingly enough, when I include it it solves the current error I was getting and creates another.  Now the error is in the actual jQuery code for the each method as $t.dradanddrop is valid but the windowMove object is still null so when it calls applyContext which does the $.each call it is using a null object which then causes it to fail.  I also noticed the same thing if I make it resizable.
0
Alex Gyoshev
Telerik team
answered on 27 Sep 2010, 03:13 PM
Hello Adam,

Can you please provide a sample solution that shows the problem, so that we can inspect and address it?

Sincerely yours,
Alex Gyoshev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Adam Gritt
Top achievements
Rank 1
answered on 27 Sep 2010, 03:23 PM
My bad, I got it working now.  It was because I was missing the telerik.draganddrop.js file on the page.  When I added it it wasn't working because I also didn't have the scripts in the correct order.  Once I corrected this and put it before the telerik.window.js file in the add order then it worked fine.  Sorry for the confusion.
Tags
Window
Asked by
nachid
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Alex
Top achievements
Rank 1
Mark Dawson
Top achievements
Rank 1
nachid
Top achievements
Rank 1
Joan Vilariño
Top achievements
Rank 2
Won
Top achievements
Rank 1
Adam Gritt
Top achievements
Rank 1
Share this question
or