-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender-template.html
More file actions
38 lines (38 loc) · 957 Bytes
/
render-template.html
File metadata and controls
38 lines (38 loc) · 957 Bytes
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<script src="jquery-1.11.2.js"></script>
<script src="underscore.js"></script>
<script src="backbone.js"></script>
</head>
<body>
<script type="text/template" id="item-template">
<div>
<input id="todo_complete" type="checkbox" <%= completed ? 'checked="checked"' : '' %>>
<%= title %>
</div>
</script>
<script>
var ItemView = Backbone.View.extend({
events: {},
render: function(){
this.$el.html(this.template(this.model.attributes));
return this;
}
});
var ListView = Backbone.View.extend({
template: _.template($("#item-template").html()),
render: function(){
var items = this.model.get('items');
_.each(items, function(item){
var itemView = new ItemView({ model: item });
this.$el.append( itemView.render().el );
}, this);
}
});
</script>
</body>
</html>