Here I am creating a new Divider with an ID, fetching the Divider, and displaying all attributes and a single attribute:
var divider = new Divider({id: "A"});
divider.fetch();
console.info(divider.attributes);
console.info(divider.get("title"));
The output of console.info(divider.attributes) shows attributes.title as an array with four strings; however; console.info(divider.get("title")) shows null. Can anyone think why it’s coming back as null? The only attribute I can get is “id”. Also, console.info(divider.attributes.title) also shows null.
Here is my Divider model:
Divider = Backbone.Model.extend({
defaults: {
"id": null,
"title": null,
"description": null
}
}
Let me know if I can provider more information. Thanks!
Glad you figured out the async issue. I ran into the same issue as you, and figured out that when the data is being returned, your model’s attributes are updated in the console. So at the time you are looking at your console, the fetch method has completed and your model has been updated.