forked from MarionetteLabs/marionette-cookbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
55 lines (45 loc) · 1.75 KB
/
index.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'>
<title>Marionette Examples: Rendering Lists</title>
<!-- A CSS normalizer -->
<link rel='stylesheet' href='../../bower_components/html5-reset/assets/css/reset.css'>
<!-- Some more style -->
<link rel='stylesheet' href='../../assets/css/main.css'>
</head>
<body>
<main>
<h1>Simple Lists</h1>
<p>
The simplest way to render a list is with an Item View. It might seem strange to use an Item View
to render a list, as opposed to a Collection or Composite View, but there <em>are</em> times when
you don't need the added functionality that those views give you.
</p>
<h2>When To Use</h2>
<p>
You should use Item Views to render your lists when you don't need to track events, like hovers
or clicks, on individual items in the list. When you need to track events you should look into one
of those other view classes.
</p>
<h2>Example</h2>
<p>
The following mark up is rendered by the code found in <code>simple-list.js</code>:
</p>
<ul class='list'></ul>
</main>
<!-- Install our three dependencies -->
<script src='../../../bower_components/jquery/dist/jquery.js'></script>
<script src='../../../bower_components/underscore/underscore.js'></script>
<script src='../../../bower_components/backbone/backbone.js'></script>
<!-- Don't forget Marionette! -->
<script src='../../../bower_components/marionette/lib/backbone.marionette.js'></script>
<script type='text/template' id='template-color-list'>
<% _.each(items, function(item){ %>
<li><%= item.colorName %></li>
<% }); %>
</script>
<!-- Our script; this is where everything happens -->
<script src='simple-list.js'></script>
</body>
</html>