dom-delegator
Decorate elements with delegated events
dom-delegator
allows you to attach an EventHandler
to
a dom element.
When event of the correct type occurs dom-delegator
will
invoke your EventHandler
This allows you to seperate your event listeners from your event writers. Sprinkle your event writers in the template in one part of your codebase. Attach listeners to the event sources in some other part of the code base.
This decouples the event definition in the DOM from your event listeners in your application code.
Also see html-delegator
for the same idea using html data-
attributes.
Example
bar baz
var document = var Delegator = var EventEmitter = EventEmitter var del = var emitter = emitter var elem = document // add individual elems. (in a different file?)deldel
Example (global listeners)
Sometimes you don't want to add events bound to an element but instead listen to them globally.
var Delegator = var d = d d
Installation
npm install dom-delegator
Contributors
- Raynos