-
Notifications
You must be signed in to change notification settings - Fork 10
/
route-based-components-jsx.html
58 lines (47 loc) · 1.29 KB
/
route-based-components-jsx.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
50
51
52
53
54
55
56
57
58
<!doctype html>
<html lang="en">
<head>
<script type="text/javascript" src="jquery-2.0.3/build/jquery.js"></script>
<script type="text/javascript" src="underscore-1.5.2/build/underscore.js"></script>
<script type="text/javascript" src="backbone-1.1.0/build/backbone.js"></script>
<script type="text/javascript" src="react-0.8.0/build/react.js"></script>
<script type="text/javascript" src="react-0.8.0/build/JSXTransformer.js"></script>
</head>
<body>
<script type="text/jsx">
/**
* @jsx React.DOM
*/
var FooComponent = React.createClass({
render : function() {
return <div>foo</div>;
}
});
var BarComponent = React.createClass({
render : function() {
return <div>bar</div>;
}
});
var Router = Backbone.Router.extend({
routes : {
"foo" : "foo",
"bar" : "bar"
},
foo : function() {
React.renderComponent(
<FooComponent />,
document.body
);
},
bar : function() {
React.renderComponent(
<BarComponent />,
document.body
);
}
});
new Router();
Backbone.history.start();
</script>
</body>
</html>