Greetings everyone, I am delving into the world of Backbone and JavaScript. My data.json file is structured as follows:
{
"locations":
[
{address:"2222", town:"Dallas"},{address:'3333', town:"Houston"},{}....
],
"items":
[
{title:"shirt", price:20},{title:"shorts", price:10},{}....
]
}
I am using jQuery Mobile to populate two distinct Listviews.
For this purpose, I have created separate Backbone models for location and item entities
Item = Backbone.Model.extend({
default:
{
title:"",
price:""
}
});
Address = Backbone.Model.extend({
default:
{
address:"",
town:""
}
});
In addition, I have established Address and Item collections in the following manner
Items = Backbone.Collection.extend({
defaults: {
model: Item
}
});
Addresses = Backbone.Collection.extend({
defaults: {
model: Address
}
});
Now, my question is how do I structure my Store model to include both address and item collections. I presume it would look something like this:
Store = Backbone.Model.extend({
addresses:[],
items:[],
url:"data.json"
});
Furthermore, could someone guide me on how to display the list view once the data has been fetched? Thank you!