/
append.html
55 lines (46 loc) · 1.34 KB
/
append.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Append Example</title>
</head>
<body>
<!-- Layout will be inserted here -->
<div class="main"></div>
<!-- Layout template -->
<script type="template" id="main">
<h1>Hello</h1>
<p></p>
</script>
<!-- Content template -->
<script type="template" id="content">
This is some content...
</script>
<!-- Required Library Dependencies -->
<script src="../test/vendor/jquery.js"></script>
<script src="../test/vendor/underscore.js"></script>
<script src="../test/vendor/backbone.js"></script>
<script src="../backbone.layoutmanager.js"></script>
<script>
// Create a Content view to be used with the Layout below.
var Content = Backbone.View.extend({
template: "#content"
});
// Create a new Layout with a sub view for content.
var main = new Backbone.LayoutManager({
template: "#main",
// This will place the contents of the Content View into the main
// Layout's <p></p>.
views: {
// Appending a new content view using the array syntax
p: [ new Content() ]
}
});
// Attach the Layout to the main container.
main.$el.appendTo(".main");
// Render the Layout
main.render();
</script>
</body>
</html>