-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_view.js.coffee
More file actions
37 lines (27 loc) · 829 Bytes
/
task_view.js.coffee
File metadata and controls
37 lines (27 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class Do.Views.TaskList extends Backbone.View
initialize: (opts) ->
@collection.bind 'add', @addRow
@collection.bind 'remove', @removeRow
render: ->
_.each @collection.models, (model) =>
@addRow(model, collection: @collection)
if @_type == 'project'
$('header').html('Project Task List')
else
$('header').html('Personal Task List')
@
addRow: (model, collection) ->
row = new Do.Views.TaskRow
model: model
collection: collection
$(@el).append row.render()
remove: ->
@collection.unbind 'add', @addRow
@collection.unbind 'remove', @removeRow
class Do.Views.TaskRow extends Backbone.View
render: ->
$(@el).html Do.Templates.task_row()
handleNameChanged: (e) ->
name = $(e.target).val()
@model.set 'name', name
@model.save()