-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.html
62 lines (46 loc) · 1.38 KB
/
test.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h3>Knockout Example</h3>
<div id="koTest">
<div data-bind="text: text"></div>
<div data-bind="react: { $: ToDoList, props: { todos: todos }}"></div>
</div>
<h3>React Example</h3>
<div id="reactTest"></div>
<script src="//cdnjs.cloudflare.com/ajax/libs/react/0.13.1/react.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/knockout/3.3.0/knockout-min.js"></script>
<script src="ideas.es5.js"></script>
<script>
var vm = {
text: "some text",
todos: ko.observableArray([
"one","two","three"
])
};
ko.applyBindings(vm, document.getElementById("koTest"));
setInterval(function () {
vm.todos.shift();
vm.todos.push("" + Math.random());
}, 100);
// react example
var reactList = ["one","two","three"];
var render = function (todos) {
React.render(
React.createElement(ToDoList, { todos: todos }),
document.getElementById("reactTest")
);
};
render(reactList);
setInterval(function () {
reactList.shift();
reactList.push("" + Math.random());
render(reactList);
}, 100);
</script>
</body>
</html>