Skip to content

Commit

Permalink
Merge branch 'sort' into form-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenpsmith committed Jan 9, 2012
2 parents ec5570a + 62a5e0b commit 3cb06ea
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ var exercise = {};

exercise.Activities = Backbone.Collection.extend({
model: exercise.Activity,
url: "exercise.json"
url: "exercise.json",
comparator: function(activity){
var date = new Date(activity.get('date'));
return date.getTime();
}
});

exercise.ActivityListView = Backbone.View.extend({
Expand All @@ -19,7 +23,7 @@ var exercise = {};
attributes: {"data-role": 'listview'},

initialize: function() {
this.collection.bind('add', this.add, this);
this.collection.bind('add', this.render, this);
this.template = _.template($('#activity-list-item-template').html());
},

Expand All @@ -36,14 +40,6 @@ var exercise = {};
container.html($(this.el));
container.trigger('create');
return this;
},

add: function(item) {
var activitiesList = $('#activities-list'),
template = this.template;

activitiesList.append(template(item.toJSON()));
activitiesList.listview('refresh');
}
});

Expand Down

0 comments on commit 3cb06ea

Please sign in to comment.