Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Proper Way To Access Model(s) Data From Collection In Backbone

/*you must write {model: song} by the way. You CANNOT use a different word*/
const AppView =   Backbone.View.extend({
el: $("#content"),
initialize: function()
{
  console.log(this.model.models[0].get("name"));
this.$el.html("this.model.get('name')");
}

});
const song = new Song();
const songs = new Songs();
songs.add(song);
 
const appView = new AppView({model: songs});
 
PREVIOUS NEXT
Tagged: #Proper #Way #To #Access #Data #From #Collection #In #Backbone
ADD COMMENT
Topic
Name
8+4 =