-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlive-text-input.html
37 lines (31 loc) · 1.05 KB
/
live-text-input.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Example: live text input</title>
</head>
<body>
<!-- target element -->
<div id="container"></div>
<!-- templates -->
<template class="magery-templates">
<div data-template="main" id="container">
<h1>Hello, {{name}}!</h1>
<input type="text" oninput="updateName(event)" />
</div>
</template>
<script src="../build/magery.js"></script>
<script>
var templates = Magery.compile('.magery-templates');
var container = document.getElementById('container');
var data = {name: 'world'};
templates['main'].bind({
updateName: function (event) {
data.name = event.target.value;
Magery.patch(templates, 'main', data, container);
}
});
Magery.patch(templates, 'main', data, container);
</script>
</body>
</html>