component-delegate

0.2.4 • Public • Published

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 (++== 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

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i component-delegate

    Weekly Downloads

    4,887

    Version

    0.2.4

    License

    none

    Last publish

    Collaborators

    • ockham
    • defunctzombie
    • dfcreative
    • tjholowaychuk
    • rauchg
    • retrofox
    • coreh
    • forbeslindesay
    • kelonye
    • mattmueller
    • yields
    • anthonyshort
    • ianstormtaylor
    • cristiandouce
    • swatinem
    • stagas
    • amasad
    • juliangruber
    • calvinfo
    • dominicbarnes
    • jongleberry
    • tootallnate
    • timoxley
    • jonathanong
    • queckezz
    • nami-doc
    • clintwood
    • thehydroimpulse
    • stephenmathieson
    • trevorgerhardt
    • timaschew
    • hughsk