-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathapp.js
57 lines (48 loc) · 1.22 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
require(['libs/text!header.html', 'libs/text!home.html', 'libs/text!footer.html'], function (headerTpl, homeTpl, footerTpl) {
var ApplicationRouter = Backbone.Router.extend({
routes: {
"": "home",
"*actions": "home"
},
initialize: function() {
this.headerView = new HeaderView();
this.headerView.render();
this.footerView = new FooterView();
this.footerView.render();
},
home: function() {
this.homeView = new HomeView();
this.homeView.render();
}
});
HeaderView = Backbone.View.extend({
el: "#header",
templateFileName: "header.html",
template: headerTpl,
initialize: function() {
// $.get(this.templateFileName, function(data){console.log(data);this.template=data});
},
render: function() {
$(this.el).html(_.template(this.template));
}
});
FooterView = Backbone.View.extend({
el: "#footer",
template: footerTpl,
render: function() {
this.$el.html(_.template(this.template));
}
})
HomeView = Backbone.View.extend({
el: "#content",
// template: "home.html",
template: homeTpl,
initialize: function() {
},
render: function() {
$(this.el).html(_.template(this.template));
}
});
app = new ApplicationRouter();
Backbone.history.start();
});