Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

add event delegation to ever event emitters

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 README.md
Octocat-spinner-32 index.js
Octocat-spinner-32 package.json
Octocat-spinner-32 test.js
README.md

ever-delegate

DOM event delegation, a la jQuery's el.on('click', 'selector > selector') method.

var ever = require('ever')
  , sel = require('cssauron-html')
  , delegate = require('ever-delegate')


delegate(ever(document.body), sel('a[href^=/]'))
  .on('click', function(ev) {
    console.log(this)   // <-- the <a> element selected by the above
  })

api

delegate(event emitter, filterFunction) -> delegate event emitter

Create a delegate event emitter. Works with any event emitter that emits DOM event objects.

filterFunction is a function that takes one argument -- a node -- and returns whether or not that node should be considered a match or not. This is compatible with the matchesSelector spec (available as webkitMatchesSelector or mozMatchesSelector). It's also compatible with CSSauron selectors.

license

MIT

Something went wrong with that request. Please try again.