forked from tilemill-project/tilemill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjects.bones
38 lines (38 loc) · 1.24 KB
/
Projects.bones
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
36
37
38
view = Backbone.View.extend({
events: {
'click .actions a[href=#add]': 'add',
'click .delete': 'del'
},
initialize: function() {
_(this).bindAll('render', 'add', 'del');
this.collection.bind('add', this.render);
this.collection.bind('remove', this.render);
this.render();
},
render: function() {
$(this.el).html(templates.Projects(this.collection));
return this;
},
add: function() {
var model = new models.Project({}, {collection:this.collection});
new views.ProjectAdd({ el: $('#popup'), model: model });
},
del: function(ev) {
var id = $(ev.currentTarget).attr('id');
var model = this.collection.get(id);
new views.Modal({
content: _('Are you sure you want to delete "<%=id%>?"').template({id:id}),
callback: _(function() {
model.destroy({
success: function() {
this.collection.remove(model);
}.bind(this),
error: function(model, err) {
new views.Modal(err);
}.bind(this)
});
}).bind(this)
});
return false;
}
});