mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-06-27 16:00:04 +08:00
34 lines
622 B
JavaScript
34 lines
622 B
JavaScript
var app = app || {};
|
|
|
|
(function() {
|
|
|
|
app.ListView = Backbone.View.extend({
|
|
|
|
el: $("#main .children"),
|
|
|
|
events: {
|
|
'click #add': 'addTask'
|
|
},
|
|
|
|
initialize: function() {
|
|
this.collection = new app.List();
|
|
this.collection.fetch();
|
|
this.listenTo(this.collection, 'add', this.renderTask);
|
|
},
|
|
|
|
render: function() {
|
|
this.collection.each(function(task) {
|
|
this.renderTask(task);
|
|
}, this);
|
|
},
|
|
|
|
renderTask: function(task) {
|
|
var taskView = new app.TaskView({
|
|
model: task
|
|
});
|
|
this.$el.append(taskView.render().el);
|
|
}
|
|
|
|
});
|
|
|
|
}()); |