This is a migrated thread and some comments may be shown as answers.
Centering a window with ajax -loaded content
5 Answers 73 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
roger
Top achievements
Rank 1
roger asked on 03 Dec 2010, 04:00 PM
Hey guys

I don't know if it's me or a bug, but I'm not able to center a window which loads content via ajax (contentUrl).

Instead of a "real" center the top left corner of the window gets centered.

I guess it's because the center is being done before the content finished loaded.

A workaround is to center the window inside the success event of the ajax request.

Thanks

5 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 07 Dec 2010, 11:12 AM
Hi roger,

Indeed, centering the window before the content loads is not possible because its size is not yet determined. You can either:

  • bind an event handler to the refresh event and center the window
  • specify the window width / height before centering it


Best wishes,
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
Bernt
Top achievements
Rank 1
answered on 18 Nov 2011, 01:45 PM
Hi Alex,

Do you have a sample code on how to implement the refresh event handler?

Best wishes,
Rune
0
Dimo
Telerik team
answered on 18 Nov 2011, 02:31 PM
Hello Rune,

Please refer to our demos:

http://demos.telerik.com/aspnet-mvc/window/clientsideevents

http://demos.telerik.com/aspnet-mvc/window/clientsideapi

Regards,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Paul
Top achievements
Rank 1
answered on 16 Dec 2011, 08:41 PM

Below is what I do.  The window size is never set. Trigger center code on window events as well as browser events.


.ClientEvents(events => events
.OnLoad(centerWindow")
.OnOpen("centerWindow")
.OnActivate("centerWindow")
.OnRefresh("centerWindow"))

 

 

 

<script type="text/javascript">
    function centerWindow() {
        $("#LoginWindow").data("tWindow").center();
        $("#UserName").focus();
        }
 
    window.onresize = function(event) {
        centerWindow();
    }
 
     
</script>
0
Dimo
Telerik team
answered on 19 Dec 2011, 11:15 AM
Hi Paul,

Your code works correctly on my side and the open Window is centered according to the browser window. The center() method does not set any widths or heights.

In addition, it is good to make a check whether the Window component exists and is initialized.

Kind regards,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Window
Asked by
roger
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Bernt
Top achievements
Rank 1
Dimo
Telerik team
Paul
Top achievements
Rank 1
Share this question
or