This is a migrated thread and some comments may be shown as answers.

Configuration of Window

3 Answers 131 Views
Window
This is a migrated thread and some comments may be shown as answers.
Victoria
Top achievements
Rank 1
Victoria asked on 11 Oct 2012, 09:01 PM
Hi,
My application has several Window objects sharing the same configuration settings. Is it possible to specify them somewhere and pass that on to kendoWindow when creating a window? Currently I have the following:

var win1 = $("#window1").kendoWindow({
        height: "600px",
        visible: false,
        width: "900px",
        modal: true,
        open: onOpenW
    }).data("kendoWindow");

var win2 = $("#window2").kendoWindow({
        height: "600px",
        visible: false,
        width: "900px",
        modal: true,
        open: onOpenW
    }).data("kendoWindow");

And I would like to have something like this (or whatever the syntax will be):

  config = {  height: "600px",
        visible: false,
        width: "900px",
        modal: true,
        open: onOpenW }

var win2 = $("#window2").kendoWindow({
        config
    }).data("kendoWindow");

Thanks!

3 Answers, 1 is accepted

Sort by
0
Accepted
Alex Gyoshev
Telerik team
answered on 12 Oct 2012, 07:40 AM
Hello Victoria,

You almost nailed it! Just drop the braces when instantiating the window:

var config = {  height: "600px",
        visible: false,
        width: "900px",
        modal: true,
        open: onOpenW
};

var win2 = $("#window2").kendoWindow(config).data("kendoWindow");


All the best,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Victoria
Top achievements
Rank 1
answered on 16 Oct 2012, 12:24 AM
Great, thank you!

Another quick question regarding the same functionality. What if I'd like to have some properties to be "common properties" and some that are unique? For example, my config variable won't have "open" specified, but I'd like each window to execute its own "open" function:

var win1 = $("#window1").kendoWindow({
        height: "600px",
        visible: false,
        width: "900px",
        modal: true,
        open: function () {
kendo.bind($("#test1"), testModel1)
}
    }).data("kendoWindow");

var win2 = $("#window2").kendoWindow({
        height: "600px",
        visible: false,
        width: "900px",
        modal: true,
         open: function () {
kendo.bind($("#test2"), testModel2)
}
    }).data("kendoWindow");

Can I still make it working with common config variable and specify remaining properties somehow?

var config = {  height: "600px",
        visible: false,
        width: "900px",
        modal: true
};

var win2 = $("#window2").kendoWindow({ config,
open: function(){...}
     }).data("kendoWindow");


Thank you!
Victoria
0
Accepted
Nohinn
Top achievements
Rank 1
answered on 16 Oct 2012, 09:29 AM
Hello Victoria, you should pass a JSON object to the initialization of the window control.
If you have already some properties within a config variable (as in your case) and you want to add after that an specific option like the open callback, you can use this:
var win2 = $('#window2').kendoWindow($.extend({}, config, {open: function() { ... }})).data("kendoWindow");
Tags
Window
Asked by
Victoria
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Victoria
Top achievements
Rank 1
Nohinn
Top achievements
Rank 1
Share this question
or