mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-06-28 16:10:05 +08:00
85a1b0674d
* Setting each task's `margin-left` according to it's parent * Putting a view element inside another view element was causing issues
39 lines
850 B
JavaScript
39 lines
850 B
JavaScript
var app = app || {};
|
|
|
|
(function() {
|
|
|
|
app.ListView = Backbone.View.extend({
|
|
|
|
el: $("#main .children"),
|
|
|
|
events: {
|
|
'click #add': 'addTask'
|
|
},
|
|
|
|
initialize: function() {
|
|
app.Tasks = 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
|
|
});
|
|
var a = taskView.render();
|
|
if (a.model.get('parent_id')!=0)
|
|
a.$el.insertAfter($('*[data-id="'+a.model.get('parent_id')+'"]').parents('li:first'));
|
|
else
|
|
this.$el.append(a.el);
|
|
console.log(a.$input.prop('selectionStart'));
|
|
}
|
|
|
|
});
|
|
|
|
}()); |