36 lines
785 B
Markdown
Executable file
36 lines
785 B
Markdown
Executable file
custom-event
|
|
============
|
|
### Cross-browser `CustomEvent` constructor
|
|
|
|
[](https://saucelabs.com/u/custom-event)
|
|
|
|
[](https://travis-ci.org/webmodules/custom-event)
|
|
|
|
https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent.CustomEvent
|
|
|
|
|
|
Installation
|
|
------------
|
|
|
|
``` bash
|
|
$ npm install custom-event
|
|
```
|
|
|
|
|
|
Example
|
|
-------
|
|
|
|
``` js
|
|
var CustomEvent = require('custom-event');
|
|
|
|
// add an appropriate event listener
|
|
target.addEventListener('cat', function(e) { process(e.detail) });
|
|
|
|
// create and dispatch the event
|
|
var event = new CustomEvent('cat', {
|
|
detail: {
|
|
hazcheeseburger: true
|
|
}
|
|
});
|
|
target.dispatchEvent(event);
|
|
```
|