-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable.html
49 lines (46 loc) · 1.15 KB
/
table.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sample Knockoutjs App</title>
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
</head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
<body>
<table>
<thead>
<tr><th>Full Name</th><th>Username</th><th>Email</th><th>Website</th></tr>
</thead>
<tbody data-bind="foreach: users">
<tr>
<td data-bind="text: name"></td>
<td data-bind="text: username"></td>
<td data-bind="text: email"></td>
<td data-bind="text: website"></td>
</tr>
</tbody>
</table>
<script type='text/javascript' src='./js/knockout-3.5.0.js'></script>
<script>
function View(data){
var self = this;
this.users = ko.observableArray(data);
}
function getUsers(){
$.get("https://jsonplaceholder.typicode.com/users/", function(returnedData) {
// This callback is executed if the post was successful
ko.applyBindings(new View(returnedData));
})
}
getUsers();
</script>
</body>
</html>