-
Notifications
You must be signed in to change notification settings - Fork 3
13: 予定を時間順でソートして表示する
Kazuhito Hokamura edited this page Oct 23, 2013
·
2 revisions
予定の一覧が追加した順番になっているので、時間でソートするようにします。
//...
App.Schedules = Backbone.Collection.extend({
model: App.Schedule,
findByDate: function(date) {
var format = 'YYYY-MM-DD';
var targetDate = moment(date).format(format);
return this.chain()
.select(function(model) {
return model.dateFormat(format) === targetDate;
})
.sortBy(function(model) {
return model.get('datetime');
})
.value();
}
});
予定が時間順に並び替わるようになれば成功です。