I'm trying to figure out how to split my events into days (mon-sun).
Within my collection, I'm trying to parse the events based upon their date like thus
var eventCollectionView = Backbone.View.extend({
initialize: function() {
this.listenTo(this.collection, "reset", this.render);
},
tagName: "div",
className: "events",
render: function(){
var Monday = new eventDayCollectionView();
var Tuesday;
var Wednesday;
var Thursday;
var Friday;
var Saturday;
var Sunday;
this.collection.each(function(eventItem) {
var searchDate = eventItem.get('searchDate');
if (date < 1)
monday.add(eventItem)
else if (date < 2)
tuesday.add(eventItem)
}, this);
for Monday
append the monday objects to monday div
for Tuesday
append the tuesday objects to tuesday div
return this;
}
});
Above is the pseudocode, however, this entire collection is being set as the html of a div called events. But instead, I want to append the monday-sunday events to separate divs. However, is this the best way to go about approaching it? Because I want to expand this not just to a week, but to a month, and it seems like an awful lot of hardcoding. Any suggestions?
I did something just like this, although only for two <div>
s. I don't think it was programmatic allocation to the <div>
s, but that shouldn't be too hard.
See this: Can't get backbone events to fire; render models to more than one location
There's some decent discussion there.