forked from zhangguixu/sourcecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.html
More file actions
45 lines (40 loc) · 873 Bytes
/
template.html
File metadata and controls
45 lines (40 loc) · 873 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
39
40
41
42
43
44
45
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>demo 1</title>
</head>
<body>
<div id="divTip"></div>
<script src="../lib/jquery-1.12.2.js"></script>
<script src="../lib/underscore.js"></script>
<script src="../lib/backbone.js"></script>
<script>
$(function(){
//定义模型类
window.Test = Backbone.Model.extend({
defaults : {
content : ''
}
});
//创建集合模型类
window.TestList = Backbone.Collection.extend({
model : Test
});
//向模型添加数据
var data = new TestList({
content : 'hello,backbone!'
});
//创建View对象
window.TestView = Backbone.View.extend({
el : $('body'),
initialize : function(){
$('#divTip').html(data.models[0].get('content'));
}
});
//实例化View对象
window.App = new TestView;
});
</script>
</body>
</html>