I\'m trying to make a small backbone.js app, but struggle with the order of things.
In my html file, I have two script blocks in the header:
In this case you should bootstrap your model data so that it's available on page load.
Instead of
window.model.fetch();
put something like this in (if using a .erb)
Otherwise you need to render the view once the model is fetched e.g.
bind the view to render when the model changes
initialize: function () {
_.bindAll(this, 'render');
this.model.on("change", this.render);
},
or handle the success of the model.fetch and render the view
window.model.fetch({
success: function (model, response) {
window.MyApp.myModelView.render();
}
});