Aaron Stanley King

I solve problems -- occasionally code is involved.

Kendo UI window not centering for you?

Telerik's Kendo UI

I recently had to build a new site and I wanted to use Kendo UI.  It's really good stuff and there are plenty of samples.  The thing about learning from samples is that sometimes the sample is incomplete.  Like this weird thing I noticed with the code I downloaded from.  When you click an item in the ListView it opens detail in a Kendo Window.  Pretty cool, but it's not centered.  It puts the window at the bottom of the window for some reason.

Let's look at the code (/Scripts/App/store.js).

_openWindow = function (template, viewModel) { 
              // Create a placeholder element. 
              var window = $(document.createElement('div')); 
              // Apply template to the placeholder element, and bind the viewmodel. 
              var templateHtml = $(template).html(); 
              kendo.bind(window, viewModel); 
              // Add window placeholder to the body. 
              // Turn placeholder into a Window widget. 
                  width: config.albumDetailsWindowWidth, 
                  title: viewModel.data.Title, 
                  resizable: false, 
                  close: function () { 
                      // When the window is closed, remove the element from the document. 
              // Center and show the Window.