Kendo UI Center window after updating large content

Using MVC 4 , I will add a blank window and hide it. When I click the button, I call this javascript to get the contents and center window:

  var win = $("#myWindow").data("kendoWindow"); win.content("Loading..."); win.refresh({ url: "@Url.Action("MyAction", "MyController")", data: { userloginid: "AAA" } }); win.center(); win.open(); 

The contents are larger than a default window , so the calculation of win.center() turned off, omitting the window too much.

How to get the window in the center based on the content obtained with the refresh () command.

+4
source share
1 answer

It seems that the problem is that you are centering the window, and some time after that new content is loading.

In other words: The center is called before the window gets a new size through the loaded content.

To prevent this, you must bind windows to the event and center it.

Something along the lines ( Beware: register this event only once ):

 var win = $("#myWindow").data("kendoWindow"); win.bind("refresh", function() { win.center(); win.open(); }); 
+9
source

All Articles