component-delegate
Event delegation component
Last updated 4 years ago by ockham .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install component-delegate 
SYNC missed versions from official npm registry.

delegate

Low-level event delegation component.

Installation

$ component install component/delegate

Example

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);

API

.bind(el, selector, type, callback, [capture])

Bind and return a callback which may be passed to .unbind().

.unbind(el, type, callback, [capture])

Unbind.

License

MIT

Current Tags

  • 0.2.4                                ...           latest (4 years ago)

4 Versions

  • 0.2.4                                ...           4 years ago
  • 0.2.3                                ...           6 years ago
  • 0.2.2                                ...           6 years ago
  • 0.2.1                                ...           7 years ago

Copyright 2014 - 2017 © taobao.org |