How do I set the content of a Kendo window?

Greg Gum picture Greg Gum · Jan 9, 2014 · Viewed 25.2k times · Source

I have this window:

   @(Html.Kendo().Window()
  .Name("errorWindow") 
  .Title("")
  .Content(@<text>
            //Put text here
     </text>)
  .Draggable() //Enable dragging of the window
  .Resizable() //Enable resizing of the window
  .Modal(true)

  .Visible(false)
  )

which is converted to this on the client:

jQuery(function(){jQuery("#errorWindow").kendoWindow({"modal":true,"iframe":false,"draggable":true,"pinned":false,"title":"","resizable":true,"content":null,"actions":["Close"]});});

Which I can call with this JScript:

function onAjaxFailure(data) {
        var window = $("#errorWindow").data("kendoWindow");
        window.center().open();
    }

But how do I put the text in the window? In other words, the "data" parameter will be the text to be shown in the error windows.

Answer

Lars H&#246;ppner picture Lars Höppner · Jan 9, 2014

Use kendoWindow.content(data), e.g.:

$("#dialog").kendoWindow({
    modal: true,
    visible: false,
});

setTimeout(function () {
    var kendoWindow = $("#dialog").data("kendoWindow");
    kendoWindow.content("show this");
    kendoWindow.center().open();
}, 2000);

(demo)

If you want it to show in a certain element inside the window, you can search for it in kendoWindow.element.