hi, i have a simple MVVM listview that get data from a json webservice.:
<div data-role="view"
data-model="app.products.viewModel" >
<ul
data-role="listview"
data-bind="source: productsDS"
data-template="product-template">
</ul>
</div>
and my viewModel:
(function (global) {
var ProductViewModel,
app = global.app = global.app || {};
ProductViewModel = kendo.data.ObservableObject.extend({
productDS: "",
init: function() {
var that = this,
dataSource;
kendo.data.ObservableObject.fn.init.apply(that, []);
// Get Session from localStorage when user login.
var session = getSession();
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "http:/.... my service" + session,
dataType: "json"
}
},
schema: {
data: "results.data"
}
});
that.set("productDS", dataSource);
}
});
app.products = {
viewModel: new ProductViewModel()
};
})(window);
When i start the app, i get no data from the datasource because session is still "undefined". Session is a value the user get doing a previous login.
If i refresh the app (appBuilder Simulator), then the session is not nul and everything works.
how i can trigger the dataSource when i have the session already?
<div data-role="view"
data-model="app.products.viewModel" >
<ul
data-role="listview"
data-bind="source: productsDS"
data-template="product-template">
</ul>
</div>
and my viewModel:
(function (global) {
var ProductViewModel,
app = global.app = global.app || {};
ProductViewModel = kendo.data.ObservableObject.extend({
productDS: "",
init: function() {
var that = this,
dataSource;
kendo.data.ObservableObject.fn.init.apply(that, []);
// Get Session from localStorage when user login.
var session = getSession();
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "http:/.... my service" + session,
dataType: "json"
}
},
schema: {
data: "results.data"
}
});
that.set("productDS", dataSource);
}
});
app.products = {
viewModel: new ProductViewModel()
};
})(window);
When i start the app, i get no data from the datasource because session is still "undefined". Session is a value the user get doing a previous login.
If i refresh the app (appBuilder Simulator), then the session is not nul and everything works.
how i can trigger the dataSource when i have the session already?