Last change
on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
785 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | custom-event
|
---|
| 2 | ============
|
---|
| 3 | ### Cross-browser `CustomEvent` constructor
|
---|
| 4 |
|
---|
| 5 | [![Sauce Test Status](https://saucelabs.com/browser-matrix/custom-event.svg)](https://saucelabs.com/u/custom-event)
|
---|
| 6 |
|
---|
| 7 | [![Build Status](https://travis-ci.org/webmodules/custom-event.svg?branch=master)](https://travis-ci.org/webmodules/custom-event)
|
---|
| 8 |
|
---|
| 9 | https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent.CustomEvent
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | Installation
|
---|
| 13 | ------------
|
---|
| 14 |
|
---|
| 15 | ``` bash
|
---|
| 16 | $ npm install custom-event
|
---|
| 17 | ```
|
---|
| 18 |
|
---|
| 19 |
|
---|
| 20 | Example
|
---|
| 21 | -------
|
---|
| 22 |
|
---|
| 23 | ``` js
|
---|
| 24 | var CustomEvent = require('custom-event');
|
---|
| 25 |
|
---|
| 26 | // add an appropriate event listener
|
---|
| 27 | target.addEventListener('cat', function(e) { process(e.detail) });
|
---|
| 28 |
|
---|
| 29 | // create and dispatch the event
|
---|
| 30 | var event = new CustomEvent('cat', {
|
---|
| 31 | detail: {
|
---|
| 32 | hazcheeseburger: true
|
---|
| 33 | }
|
---|
| 34 | });
|
---|
| 35 | target.dispatchEvent(event);
|
---|
| 36 | ```
|
---|
Note:
See
TracBrowser
for help on using the repository browser.