event-plugin
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "event-plugin", | ||
"description": "Declaratively add event listeners to your views.", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"homepage": "https://github.com/flams/event-plugin", | ||
@@ -6,0 +6,0 @@ "licenses": [ |
@@ -22,4 +22,46 @@ Event plugin | ||
doc is coming... | ||
Init event plugin and define event handlers: | ||
```js | ||
var eventPlugin = new EventPlugin({ | ||
toggle: function (event, node) { | ||
// do something with... | ||
// event is the original event | ||
// node is the dom node that was clicked | ||
} | ||
}); | ||
``` | ||
```html | ||
<!-- The toggle function will be called on click, on the propagation phase --> | ||
<button data-event="listen: click, toggle, true">Change route</button> | ||
``` | ||
When ready, attach the behavior to the dom via Seam: | ||
```js | ||
var Seam = require("seam"); | ||
var seam = new Seam({ | ||
event: eventPlugin | ||
}); | ||
seam.apply(document.querySelector("button")); | ||
``` | ||
You can also use the delegation method from event to delegate events to a parent DOM element. | ||
This improves performance are less event listeners are bound to the DOM. This is especially | ||
relevant to lists. | ||
```html | ||
<!-- The ul will listen to click event and call the toggle handler if an element matching 'a' is targeted. | ||
The bubbling phase will be listened to in this case --> | ||
<ul data-event="delegate: a, click, toggle, false"> | ||
<li><a href="#link1">link1</a></li> | ||
<li><a href="#link2">link2</a></li> | ||
<li><a href="#link3">link3</a></li> | ||
</ul> | ||
``` | ||
LICENSE | ||
@@ -26,0 +68,0 @@ ======= |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7386
70