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

delegate

Low-level event delegation component. Forked from component/delegate for use with browserify.

Installation

$ npm install delegate-events

Example

var delegate = require('delegate-events');
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.

Tests

  • Run npm test.
  • Open test/index.html in a browser.
  • Open the js console and verify that interacting with the elements works as they say they should.

License

MIT

Current Tags

  • 1.1.1                                ...           latest (10 years ago)

3 Versions

  • 1.1.1                                ...           10 years ago
  • 1.1.0                                ...           11 years ago
  • 1.0.0                                ...           11 years ago
Maintainers (1)
Downloads
Total 3
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE