$ gnpm install component-delegate
Low-level event delegation component.
$ component install component/delegate
var delegate = require('delegate');
var ul = document.querySelector('ul');
var n = 0;
var fn = delegate.bind(ul, 'li a', 'click', function(e){
console.log(e.target);
console.log(e.delegateTarget); // => "<a>"
if (++n == 3) {
console.log('unbind');
delegate.unbind(ul, 'click', fn, false);
}
}, false);
Bind and return a callback which may be passed to .unbind()
.
Unbind.
MIT
Copyright 2013 - present © cnpmjs.org | Home |