Is there a way to just pass content to a window instead of having the window load its data from the element used to initialize it? Right now I'm displaying a window after a user clicks a help link like this:
deleteAttribute = function(evt){
evt.preventDefault();
$(evt.target).kendoWindow({
position: "right",
height: '100px',
title: 'Confirm Deletion',
width: '325px'
});
var win = $(evt.target).data('kendoWindow');
win.content(Mustache.to_html($('#confirmDeleteAttributeTemplate').html(), {id: $(evt.target).closest('li.attribute').attr('id')}));
win.open();
win.center();
};
I want the window to position itself near the delete link...that's why I want to use evt.target to initialize the window. The content of the delete link is an icon. Passing in content using the content method appends the content to the window instead of overwriting it. The window also removes the event target from the DOM???
*** Update
I am now using this code:
deleteAttribute = function(evt){
evt.preventDefault();
var win = $('.window').data('kendoWindow');
if(!win) {
$('.window').kendoWindow({
title: 'Confirm Deletion',
width: '325px',
height: '100px'
})
.data('kendoWindow');
win = $('.window').data('kendoWindow');
}
else {
win.close();
win.setOptions({
title: 'Confirm Deletion',
width: '325px',
height: '100px'
});
}
win.content(Mustache.to_html($('#confirmDeleteAttributeTemplate').html(), {id: $(evt.target).closest('li.attribute').attr('id')}));
win.center();
win.open();
};
There are more than one link on the page to open a window, so I check for the kendoWindow object first. I think centering the window in the viewport looks the best, but for some reason if this function creates and opens the window, it is centered relative to the document. If this function opens an existing window instead, it is centered in the viewport correctly. Even if the function creates and opens the windows, subsequent invocations center the window in the viewport. I must be missing something here.
deleteAttribute = function(evt){
evt.preventDefault();
$(evt.target).kendoWindow({
position: "right",
height: '100px',
title: 'Confirm Deletion',
width: '325px'
});
var win = $(evt.target).data('kendoWindow');
win.content(Mustache.to_html($('#confirmDeleteAttributeTemplate').html(), {id: $(evt.target).closest('li.attribute').attr('id')}));
win.open();
win.center();
};
I want the window to position itself near the delete link...that's why I want to use evt.target to initialize the window. The content of the delete link is an icon. Passing in content using the content method appends the content to the window instead of overwriting it. The window also removes the event target from the DOM???
*** Update
I am now using this code:
deleteAttribute = function(evt){
evt.preventDefault();
var win = $('.window').data('kendoWindow');
if(!win) {
$('.window').kendoWindow({
title: 'Confirm Deletion',
width: '325px',
height: '100px'
})
.data('kendoWindow');
win = $('.window').data('kendoWindow');
}
else {
win.close();
win.setOptions({
title: 'Confirm Deletion',
width: '325px',
height: '100px'
});
}
win.content(Mustache.to_html($('#confirmDeleteAttributeTemplate').html(), {id: $(evt.target).closest('li.attribute').attr('id')}));
win.center();
win.open();
};
There are more than one link on the page to open a window, so I check for the kendoWindow object first. I think centering the window in the viewport looks the best, but for some reason if this function creates and opens the window, it is centered relative to the document. If this function opens an existing window instead, it is centered in the viewport correctly. Even if the function creates and opens the windows, subsequent invocations center the window in the viewport. I must be missing something here.