-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
e.g. if you have a ul full of li elements and you do
dom('ul').on('click', function(el) {
console.log(el.target)
})
then it should fire for ul and any element that is a descendant of ul
jquery works this way using the same .on syntax by default, e.g. http://jsfiddle.net/YFF2k/2/ (open console and click on some stuff)
there are a number of modules that do this on npm already:
- https://www.npmjs.org/package/component-delegate
- https://github.com/conradz/chi-events#example
- https://github.com/avetisk/ak-delegate/blob/master/lib/delegate.js
- https://www.npmjs.org/package/dom-delegate
- https://www.npmjs.org/package/dom-delegator
- https://www.npmjs.org/package/domy-events
we should probably use dom-delegator cause raynos wrote it :)
the only tricky part is that it would change the default behavior for .on to not only match the element but the element plus all children elements
Metadata
Metadata
Assignees
Labels
No labels