I am having trouble loading some json data from a file and showing as the options for a select list in a kendo mobile app. Can anyone spot what the issue is please?
My select item looks like this
<li>
<select data-bind="value:model.product, source:products" data-text-field="name" data-value-field="name" >
</select>
Products
</li>
I have also tried datasource instead of source but had no luck.
My datasource in my view model is setup as follows:
self.products = new kendo.data.DataSource({
transport: {
read: {
url: "scripts/products.json",
dataType: "json"
}
}
});
My json file looks like this:
[
{ "name": "Product 1", "owner": "Test" },
{ "name": "Product 2", "owner": "Test" }
]
When I run my app the select list is empty.
If I change my self.products to be inline json like below then it works ok. However, I would like to load this from a file.
self.products = [
{ name: "Product 1", owner: "Test" },
{ name: "Product 2", owner: "Test" }
];
Thanks
My select item looks like this
<li>
<select data-bind="value:model.product, source:products" data-text-field="name" data-value-field="name" >
</select>
Products
</li>
I have also tried datasource instead of source but had no luck.
self.products = new kendo.data.DataSource({
transport: {
read: {
url: "scripts/products.json",
dataType: "json"
}
}
});
My json file looks like this:
[
{ "name": "Product 1", "owner": "Test" },
{ "name": "Product 2", "owner": "Test" }
]
When I run my app the select list is empty.
If I change my self.products to be inline json like below then it works ok. However, I would like to load this from a file.
self.products = [
{ name: "Product 1", owner: "Test" },
{ name: "Product 2", owner: "Test" }
];