I seem to have run into a problem,
Can anyone spot why nothing is put into the div id “app”??
From the link:
JS –
var MyModel = Backbone.Model.extend();
var data = {
first: 'hello',
second: 'there'
};
var myModel = new MyModel(data);
var MyView = Backbone.View.extend({
model: myModel,
el: $('#app'),
initialize: function(){
this.render();
},
render: function(){
this.$el.html(this.model.toJSON());
}
});
var myView = new MyView();
I’m sure it’s just me being a BackboneJS noob.
oh, you’re trying to pass an object to
.htmlwhen it only takes a string. UseJSON.stringify(this.model.toJSON())if you want to do something weird like that.