Hello! I am new to learning Backbone.js and would love some suggestions from the experts out there.
Here is a snippet of my code:
app.Collections.UserCollection = Backbone.Collection.extend({
model: app.Models.IdModel,
url: "/test/test_data.json"
})
var profileDataCollection = new app.Collections.UserCollection();
profileDataCollection.fetch({
success: function(data){
console.log(data); // this will return JSON data
}
});
The data returned from fetch() looks like this:
{
"msg":[
{
"firstname":"Abc",
"lastname":"Xyz"
},
{
"firstname":"Test",
"lastname":"Test"
},
{
"firstname":"Klm",
"lastname":"Nop"
}
],
"flash_message":"",
"log":[
]
}
I'm curious how I can access the collection for the "msg" property. This way, I can pass it to my view as shown here:-
new app.Views.UsersView( { collection: profileDataCollection });