forked from tastejs/todomvc
/
app.js
45 lines (34 loc) · 791 Bytes
/
app.js
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
39
40
41
42
43
/*global $*/
var todoList = new TodoList();
var app = new Backbone.Marionette.Application();
app.bindTo(todoList, 'all', function () {
if (todoList.length === 0) {
app.main.$el.hide();
app.footer.$el.hide();
} else {
app.main.$el.show();
app.footer.$el.show();
}
});
app.addRegions({
header : '#header',
main : '#main',
footer : '#footer'
});
app.addInitializer(function(){
app.header.show(new Header());
app.main.show(new TodoListCompositeView({
collection : todoList
}));
app.footer.show(new Footer());
todoList.fetch();
});
app.vent.on('todoList:filter',function(filter) {
filter = filter || 'all';
$('#todoapp').attr('class', 'filter-' + filter);
});
$(function(){
app.start();
new Router();
Backbone.history.start();
});