-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
63 lines (60 loc) · 1.61 KB
/
demo.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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>demo</title>
<script type="text/javascript" src="src/require.js"></script>
<script type="text/javascript">
require.config({
paths: {
'jquery': 'src/jquery-1.11.0.min',
'databind': 'src/jquery.databind'
}
});
</script>
<style type="text/css">
li span{padding: 10px;}
</style>
</head>
<body>
<ul class="databind"
data-url="tree.json"
data-tpl="tree-tpl"
data-before_create="init">
</ul>
<ul class="data">
</ul>
<script type="text/html" id="tree-tpl">
<li>
<span>${name}</span>
<span>${gender}</span>
<span>${time}-${date}</span>
<span d-if="status != null">${status.value}</span>
<span d-if="tree != null">
<select name="tree">
<option d-for="tree" value="#{id}" #{checked}>#{name}</option>
</select>
</span>
</li>
</script>
<script type="text/javascript">
function init(params){
params['date'] = new Date().getTime();
}
require(['jquery', 'databind'], function () {
setTimeout(function () {
$('.data').databind('load', {
tpl: 'tree-tpl',
url: 'tree.json',
beforeCreate: function (val, id) {
console.log(val, id);
},
afterCreate: function () {
console.log(this);
}
});
}, 100);
});
</script>
</body>
</html>