-
Notifications
You must be signed in to change notification settings - Fork 0
/
knockoutEx5_foreach2.html
executable file
·58 lines (58 loc) · 1.51 KB
/
knockoutEx5_foreach2.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
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>knockdown.js Ex5</title>
<style>
table{
border-collapse: collapse;
border-top: 1px solid gray;
border-right: 1px solid gray;
border-bottom: 1px solid gray;
}
th{
padding: 6px;
text-align: left;
vertical-align: top;
color: #666666;
background: #eee;
border-bottom: 1px dotted #999;
border-left: 1px solid #ccc;
}
td{
padding: 6px;
border-bottom: 1px dotted #999;
border-left: 1px solid #ccc;
}
</style>
<script type="text/javascript" charset="UTF-8" src="js/lib/require.js" data-main="js/knockoutEx5_init.js"></script>
</head>
<body>
<table>
<thead>
<tr>
<th></th>
<th><a data-bind="click: sortByFristName">First name⇅</a></th>
<th><a data-bind="click: sortByLastName">Last name⇅</a></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td><input data-bind="value: firstName"/></td>
<td><input data-bind="value: lastName"/></td>
<td><button data-bind="click: addPerson, disable: disableAddPerson">Add</button></td>
</tr>
<!-- ko foreach: people -->
<tr data-bind="style: {'background-color' : ( $index() % 2 === 0 ? 'azure' : 'white')}">
<td data-bind="text: $index() + 1"></td>
<td data-bind="text: firstName"></td>
<td data-bind="text: lastName"></td>
<td><button data-bind="click: $parent.removePerson">delete</button></td>
</tr>
<!-- /ko -->
</tbody>
</table>
</body>
</html>