-
Notifications
You must be signed in to change notification settings - Fork 92
/
3.html
117 lines (105 loc) · 2.37 KB
/
3.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
<title>JRoll无限加载组件</title>
<style>
html,
body {
margin: 0;
padding: 0;
height: 100%;
background: #dadada;
}
header {
height: 44px;
line-height: 44px;
text-align: center;
background: #da020c;
color: #fff;
}
header>a {
height: 34px;
line-height: 34px;
position: absolute;
top: 5px;
left: 10px;
}
h1 {
margin: 0;
padding: 0;
font-size: 18px;
font-weight: normal;
}
#wrapper {
position: absolute;
top: 44px;
bottom: 0;
width: 100%;
}
#scroller {
margin: 0;
padding: 0;
}
.item {
height: 60px;
line-height: 60px;
border-bottom: 1px solid #ddd;
text-indent: 1em;
background: #fff;
}
.jroll-infinite-tip {
height: 44px;
line-height: 44px;
text-align: center;
}
</style>
<script src="../../vendor/arttemplate.js"></script>
<script src="../../src/jroll.js"></script>
<script src="jroll-infinite.js"></script>
</head>
<body>
<header>
<h1>第三方模板artTemplate</h1>
<a onclick="javascript:history.back()"><返回</a>
</header>
<div id="wrapper">
<div id="scroller"></div>
</div>
<script>
//模拟ajax
function ajax(parms) {
var a = [],
i;
var page = parms.url.replace("getData.do?page=", "");
for (i = 1; i <= 20; i++) {
a.push({
"index": i + (page - 1) * 20,
"text": "第三方模板artTemplate"
});
}
setTimeout(function() {
parms.success(a);
}, 800);
}
var jroll = new JRoll("#wrapper", {
scrollBarY: true
});
jroll.infinite({
getData: function(page, callback) { //获取数据的函数,必须传递一个数组给callback
ajax({
url: "getData.do?page=" + page,
success: function(data) {
callback(data);
}
});
},
compile: function(text) {
return template.compile(text);
},
template: "<div class='item'>{{index}}、{{text}}</div>" //每条数据模板
});
</script>
</body>
</html>