-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexample.html
More file actions
48 lines (39 loc) · 948 Bytes
/
example.html
File metadata and controls
48 lines (39 loc) · 948 Bytes
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
<style>
body {
padding: 50px;
font: 14px Helvetica;
}
ul li {
padding: 5px;
cursor: pointer;
}
ul li:hover {
background: #eee;
}
</style>
<ul>
<li>One <a href="#">remove</a></li>
<li>Two <a href="#">remove</a></li>
<li>Three <a href="#">remove</a></li>
</ul>
<a href="#" onclick="view.events.unbind()">Unbind</a>
<script src="build/build.js"></script>
<script>
var delegates = require('delegates');
var el = document.querySelector('ul');
var view = new ListView(el);
function ListView(el) {
this.events = delegates(el, this);
this.events.bind('click li a', 'remove');
this.events.bind('click li', 'alert');
}
ListView.prototype.remove = function(e){
var el = e.target.parentNode;
console.log('remove %s', el.textContent);
el.parentNode.removeChild(el);
};
ListView.prototype.alert = function(e){
var el = e.target;
alert(el.textContent);
};
</script>