I am working on using the declarative widget configuration so I can dynamically add stuff to the dom and wire it up with a simple kendo.bind('selector call') however I am having some issues with scoping. I am using an IIFE, creating a datasource in it, and calling bind in document ready.. if I do this...
(
function
() {
var
dataSource =
new
kendo.data.DataSource({
transport: {
read: {
// the remote service url
url: baseUrl +
"Lookup/CustomerKendo"
}
},
serverFiltering:
true
,
schema: {
data:
"Data"
}
});
// Document Ready
$(
function
() {
kendo.bind(
"#content"
);
});
}());
I get an error that dataSource does not exist. I was able to get it to work by doing this...
var
billingEdit = billingEdit || {};
(
function
() {
// Document Ready
$(
function
() {
billingEdit.dataSource =
new
kendo.data.DataSource({
transport: {
read: {
// the remote service url
url: baseAreaUrl +
"Lookup/CustomerKendo"
}
},
serverFiltering:
true
,
schema: {
data:
"Data"
}
});
kendo.bind(
"#content"
);
});
}());
and specifying billingEdit.dataSource in the data-source attribute. However, I want to avoid creating global variables. Is this possible? I also expect that if I put functions in the IIFE they will be invisible as well and I'll get more errors.
how can I have the controls be bound withing the scope of the IIFE?