forked from joaool/MotherGithub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backbone3.html
37 lines (35 loc) · 1.6 KB
/
backbone3.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Backbone v3.0</title>
</head>
<body>
<!--<script type="text/javascript" charset="utf-8" src="../rivets/dist/rivets.js" ></script>-->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<!--<script type="text/javascript" charset="utf-8" src="../q-1/q.js" ></script>
<script type="text/javascript" src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<script type="text/javascript" src="http://documentcloud.github.com/backbone/backbone-min.js"></script>-->
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js" type="text/javascript"></script>
<script type="text/javascript">
var Router = Backbone.Router.extend({//use the url to define what to do
routes:{
"foo/:bar":"paramtest", //it will take the first match
"*action":"func"// -->"post" exact match, ":post" parameter, "*post" matches anything - a splat, ":post/:id" sending 2 parameter
},
func: function(action) {
console.log("captured by func:"+action);
},
paramtest: function(p) {//gets xxx when we call with #foo/xxx if we call with #fxoo/xxx func will get it !!!
console.log("--->"+p);
}
});
new Router();
Backbone.history.start();//necessary to check for changes in the hash after calling line
console.log(document.title+"...... END..");
</script>
<a href="#foo/bar">Foo</a><br>
<a href="#joao/bar">Joao</a>
</body>
</html>