The month view will display the month as a table, just like a wall calendar. Events will show within the cell of the appropriate day. This will require several nested views, so let's begin with the Month
view. Here's how we start:
App.Views.Month = Backbone.View.extend({ template: JST.month, render: function () { this.el.innerHTML = this.template(this.model.toJSON()); var weeks = this.model.get('weeks'); for (var i = 0; i < weeks; i++) { this.$("tbody").append(new App.Views.WeekRow({ week : i, model : this.model, collection: this.collection }).render().el); } return this; } });
We'll give this class a JST.month
template and a render
method. Before we discuss the render
method, let's take a look at the template file.