Hi,
My ultimate goal is to open Kendo-Window with different content, depending which button clicked. i.e. click Btn1 will open a window with Content1, click Btn2 open Content 2 ... Btn-n opens content-n. The buttons and numbers of buttons are dynamic, so I can't statically add windows corresponding to button. Below are my approaches and their problems
ONE
Approach: Include a static Kendo-Window directive in html, and dynamically set its content url on button click. See this plunk for implementation.
Problem: the content will become stale, e.g. Btn1 opens content1, Btn2 still opens content1. In this plunk, I'm only able to reproduce it sometimes after open the windows a few times, and leave it for couple minutes, and open the window again. However, in my own project, this happens all the time.
TWO
Approach: On button click, I append a holderElement to body, and construct a new Kendo Window (new kendo.Window(holder, options)) with corresponding content url. See this plunk (create new window) for implementation.
Problem: The angular expressions are not compiled. Notice in the plunk example, there was a {{ctrl.count}} variable, when I open the window through Btn1 & Btn2, the variable shows how many times I've opened a kendo window. But in the newly created kendo-window, the varaible is not compiled at all.
THREE
Approach: On button click, I set content url in window options, then make angular to compile a kendo-window directive with this option, and attach it to document body.
01.
this
.windowOptions = {
02.
// ...
03.
}
04.
05.
this
.createWindow =
function
(url) {
06.
this
.windowOptions.content = { url:
"someUrl ..."
};
07.
08.
var
windowTemplate =
'<div kendo-window="ctrl.window" data-k-options="ctrl.windowOptions"></div>'
;
09.
var
element =
this
.$compile(windowTemplate)(
this
.$scope);
10.
$(document.body).append(element);
11.
12.
this
.window.center();
13.
this
.window.open();
14.
}
Problem: The window opens with no content. I put some debugger in kendo.all.js and found that content element is removed completely. Sometime after Kendo window is created after angular compiles, Kendo issues an ajaxRequest to retrieve content url. At this time, if I query this.wrapper.children(), I'd get 2 element - one for title bar, and 1 for content. However, the _ajaxSuccess method isn't called long after the window is opened, In this method, kendo add the retrieved html into content, but if I query this.wrapper.children() now, only 1 element for the title bar come back, content element is gone. There is nothing to add the html to! (Do you think this could be a bug?)
Idea in method TWO and THREE is that on each button click, I'll generate new Kendo Window, and on deactivate event, I'll call window.destory(). So that I won't have to worry about incorrect content.
I don't care which way, but how can I achieve what I want? Please help!