forked from RubyLouvre/avalon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test4.html
72 lines (68 loc) · 2.5 KB
/
test4.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
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<script src="avalon.js"></script>
<script>
avalon.define("xxx", function(vm) {
vm.data = [{checked: false}, {checked: false}, {checked: false}, {checked: false}]
vm.allchecked = false
vm.$one = "yyyyyyyyyyy"
vm.checkAll = function() {
var vmodel = avalon.vmodels.xxx
var bool = vmodel.allchecked = this.checked
vmodel.data.forEach(function(el) {
el.checked = bool
})
}
vm.click = function() {
vm.data.splice(1, 0, {checked: true})
}
vm.click2 = function() {
vm.object = {bbb: "4444444444"}
}
vm.object = {
aaa: "111111"
}
vm.checkOne = function($index) {
var vmodel = avalon.vmodels.xxx
avalon.bind("click", this, function() {
setTimeout(function() {
if (!this.checked) {
vmodel.allchecked = false
} else {
vmodel.allchecked = vmodel.data.every(function(el) {
return el.checked
})
}
})
})
}
})
</script>
</head>
<body ms-controller="xxx" >
<ul ms-each="data">
<li>{{el.checked}}</li>
</ul>
<div>
<ul >
<li ms-repeat="object">{{$key}}</li>
</ul>
</div>
<ol >
<li ms-repeat="object">{{$key}}</li>
</ol>
<table border="1">
<tr>
<td><input type="checkbox" ms-duplex-radio="allchecked" data-duplex-changed="checkAll"/>全选{{$one}}</td>
</tr>
<tr ms-repeat="data">
<td><input type="checkbox" ms-duplex-radio="el.checked" data-duplex-changed="checkOne(el,$index)"/>xxxxxxxxxxxx</td>
</tr>
</table>
<button type="button" ms-click="click">add</button> <button type="button" ms-click="click2">add</button>
</body>
</html>