How to close a Kendo window from within the window content? - kendo-ui

I have an application. In a button clicked I tried to open a Kendo modal window. It's opening. My application is in one domain and the content of the Kendo window is from another domain. Now I want to close the modal window with a button which is inside the Kendo window. Here the issue begins. I cannot close the modal window. I searched using Google it but did not find any solution — do you know one?

After reading your comments to my previous answer I think that you question is misleading. You talk about modal, another domain and close button but seems from your comments that nothing of that is actually relevant. I conclude from your comments that you want to place a button (actually a close button but might be any other) in a KendoUI window and in addition you want to display a page (that incidentally) is in a different domain. If this is what you actually want -and foreseeing problem related to cross-domain and security- I would recommend that you should actually use content.template and define a template including your button and an iframe referencing the page www.xyz.com.
Something like this...
var myWindow2 = $("#id2").kendoWindow({
modal : true,
draggable: false,
content : {
template: 'Close' +
'<iframe src="http://www.xyz.com" frameborder="0" class="k-content-frame"></iframe>'
},
visible : false,
width : 400,
height : 200,
resizable: false,
iframe : true
}).data("kendoWindow");
$("#open2").on("click", function () {
myWindow2.center();
myWindow2.open();
});
$("#close2").on("click", function () {
myWindow2.close();
});
You might even make the button float on top of the rest of the page by defining the following style for close button.
#close2 {
position: absolute;
top: 10px;
left: 10px;
z-index: 10000;
}

The following JavaScript code defines a button for opening a modal kendoWindow. Once clicked you can press a button inside the body of the window for closing it as you want.
JavaScript code:
var myWindow = $("#id1").kendoWindow({
title : "hi",
visible: false,
modal : true
}).data("kendoWindow");
$("#open").on("click", function () {
console.log("opening");
myWindow.center();
myWindow.open();
});
$("#close").on("click", function () {
console.log("closing");
myWindow.close();
})
and the HTML:
Open
<div id="id1">
<p>this is the content of my window</p>
Close
</div>

Related

Kendo UI kendoWindow - Causes Javascript show function to stop working

I have a Kendo window created using kendoWindow, which is called on a div. This correctly shows this div in a Kendo Window. If at some later point I then try to simply show the div using the show function, to make it appear on the page instead of in a window,
which worked perfectly fine before creating the Kendo
Window, the show doesn't work. How do I get it to show the div?
if (GC.ViewModels.Dashboard.IsSubscriberLoaded()) { // ***CREATES MY KENDO WINDOW
var $kwin = $('#complaint-dashboard-container').kendoWindow({
width: "1400px",
title: "", // ??
modal: true,
actions: ["Close"]
});
$($kwin).data("kendoWindow").center().open();
} else { // *** WON'T SHOW THE div if above has been executed at some point
$('#complaint-dashboard-container').show();
}
Answer : once you bind the div and make a widget it does not act as a normal div , if you need show the content i suggest you to get the html of the content and show in a different div

kendoui menu filter / form

I would like to have a button and when the user clicks on it a filter form pops down just below the button. I would like to utilize Kendo UI controls to achieve the effect.
In fact, what I need is almost exactly the 'filtering' that can be found on this example:
http://demos.telerik.com/kendo-ui/grid/filter-menu-customization
However, I'm not dealing with a grid of data so I can't use that example above.
There are different possible implementations. Here I will describe one based on kendoWindow since then you have a lot of possible customizations for that filtering form.
This is the HTML that includes the button:
<div>
This is the container that includes a
<button id="filter" class="k-button">Filter</button>
that is used to display a form
</div>
And then you define the HTML form. Example:
<div id="form">
<div>Filtering value:<input data-role="autocomplete"/></div>
<button class="k-button">Filter</button>
</div>
Doing the form initialization is:
var form = $("#form").kendoWindow({
title : "Filter",
visible : false,
modal : false,
draggable: false
}).data("kendoWindow");
Where initially we set the form as not visible.
You can define it as modal, draggable or even define the opening and closing effect.
Finally, for opening and placing the form just bellow the button you should:
$("#filter").on("click", function(e) {
// Find clicked button
var button = $(e.currentTarget);
// and get its position
var pos = button.offset();
// shift down the form to open by the height of the button + 5px (margin)
pos.top += button.outerHeight() + 5;
// Apply positioning to the form
form.wrapper.css(pos);
// display form
form.open();
});
You can see this here : http://jsfiddle.net/OnaBai/mpq6k/

Firefox ToolBar Button When Click Changes DOM?

New to firefox development and trying my best to figure this out.
Say I want to call a function in tap_browser.js that will modify the DOM when the user clicks on the toolbar widget, how would I do this?
This is the code I have so far
require("toolbarwidget").ToolbarWidget({
toolbarID: "nav-bar", // <-- Place widget on Navigation bar
id: "tap-icon",
label: "Tap",
contentURL: data.url("favicon.png"),
contentScriptFile: [data.url("tap_browser.js")]
});
I'm currently using a library to create the toolbar widget here: https://github.com/Rob--W/toolbarwidget-jplib
I don't know too much SDK but I helped someone with something that does. Check this out:
var my_wid = widgets.Widget({
id: "my-widget",
label: "CLIIIICK",
content: "CLICK ME",
width: 100,
onClick: function()
{
require('sdk/window/utils').getMostRecentBrowserWindow().gBrowser.contentDocument.documentElement.innerHTML = 'hi';
}
});
what this does is it shows a panel with 0 width and height, you can put stuff in there, and when it shows it executes the onShow function to change the html of the current document. its not recommended to use innerHTML, addons arent accepted. Im just showing you a quick and dirty copy paste example. One that is different from the sdk doc page "Modifying the Page Hosted by a Tab"

kendo: resize window on click

i have a kendo window which opens an iframe form. when they submit the form and it shows the results i want the window to widen. how can i set the of the window on click of button.
var window = $("#PCwindow"),
PCopen = $("#PCopen").bind("click", function() {
window.data("kendoWindow").center();
window.data("kendoWindow").open();
});
window.kendoWindow({
visible: false,
modal: true,
width: "500px",
height: "500px",
title: "Performance Checker",
content: "PCchecker.html",
iframe: true
});
i want the window to go to 700px wide
Use:
window.data("kendoWindow").setOptions({width : 700});
In addition, and in order to optimize your code, I would suggest reducing the number of times that you execute window.data("kendoWindow") by writing it as:
var window = $("#PCwindow"),
PCopen = $("#PCopen").bind("click", function () {
window.data("kendoWindow")
.center()
.open()
.setOptions({width: 700});
});

CKEditor disables all jquery dialogs

I have a problem with ckeditor and jquery dialog window.
I have a form in which I'm dragging a div to a sortable table. When dragging I'm cloneing the div and opening a jquery dialog which contains the ckeditor.
The editor is created on the dialog's open method, and is being destroyed on close.
After dragging the edtior for the first time it opens in the dialog, but then all the dialogs in the page are not opening.
I'm getting this error: Uncaught TypeError: Object [object Object] has no method 'dialog' when trying to open another dialog or drag another div with the editor.
My code is:
var CKEditor
$("#dialog_editor").dialog({
autoOpen: false,
height: 500,
width: $("#td_form").width(),
modal: true,
zIndex: -1,
buttons: [
{
text: "Save",
"class": 'btn btn_content',
click: function () {
saveEditorContent();
}
}
],
open: function (type, data) {
$(this).parent().appendTo("#form");
CKEditor = CKEditor = CKEDITOR.replace('text_editor', {
extraPlugins: 'autogrow',
removePlugins: 'resize'
});
},
close: function () {
CKEditor.destroy();
}
});
I have searched all over the web, and still found no answer to that.
I tried adding the adapters/jquery.js and still the same problem...
You should try to update the "Uploadcare" plugin to the current version, everything should be fine just after that.
I found out that the problem was in a plugin I added to the ckeditor named "Uploadcare"

Resources