-
Notifications
You must be signed in to change notification settings - Fork 3
/
router1.html
49 lines (37 loc) · 1.16 KB
/
router1.html
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
<html>
<head>
<link rel="stylesheet" href="css/styles.css" />
</head>
<body>
<div class="list"></div>
<div class="summary"></div>
<div class="details"></div>
<script type="text/javascript" src="lib/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="lib/underscore-min.js"></script>
<script type="text/javascript" src="lib/backbone-min.js"></script>
<script type="text/javascript">
Router = Backbone.Router.extend({
routes: {
"" : "list",
"employees/:id" : "summary",
"employees/:id/reports" : "reports",
"employees/:id/map" : "map"
},
list: function() {
$('.list').html('<h1>Employee List</h1>');
},
summary: function(id) {
$('.summary').html('<h1>Employee ' + id + ' Details</h1>');
},
reports: function(id) {
$('.details').html('<h1>Employee ' + id + ' Reports</h1>');
},
map: function(id) {
$('.details').html('<h1>Employee ' + id + ' Map</h1>');
}
});
app = new Router();
Backbone.history.start();
</script>
</body>
</html>