Giter VIP home page Giter VIP logo

cordova-plugin-customevent-polyfill's Introduction

cordova-plugin-custom-event

A Cordova plugin which provides the CustomEvent constructor API to Android browsers

Overview

See https://developer.mozilla.org/en-US/docs/DOM/Event/CustomEvent for the full API.

The CustomEvent constructor is a relatively recent (DOM Level 4) interface to build custom DOM events, which can then be thrown and caught by registered event listeners. It is supported by Chrome and Safari, but not by the Android webview (at least as of 4.2.2). This plugin provides that interface to Android-based Cordova apps.

Installation

Cordova 2.7 or later with cordova cli and Plugman

  • Assuming you've used cordova create to create the platforms, you can use cordova plugin add directory-of-the-customEvent-plugin to add the plugin

Usage

Basic usage

var newEvent = new CustomEvent("myAwesomeEvent");

Full example

// Register an event listener
document.addEventListener("alert_needed", function(e) {
    alert("An alert was needed, so now you got one!");
});

// Create the custom event
var make_an_alert = new CustomEvent("alert_needed",
    { bubbles: true,
      cancelable: false,
      details: "It's a custom event"
    });

// Fire the event
document.dispatchEvent(make_an_alert);

Release Notes

1.0.5 (May 5, 2015)

  • Fix typo: info.details -> info.detail

1.0.4 (April, 2014)

  • Change to being publish on NPM

1.0.3 (October 21, 2014)

  • Documentation updates.

cordova-plugin-customevent-polyfill's People

Contributors

agrieve avatar clelland avatar david-mulder avatar jpchase avatar kamrik avatar

Watchers

 avatar  avatar  avatar

cordova-plugin-customevent-polyfill's Issues

Unable to transfer parameters under IOS system

var event = new CustomEvent('resume', { 'detail': {hello: "xiaohao!"} });
window.dispatchEvent(event);
window.addEventListener("resume", function(e) {
  alert(e.detail.hello); // the detail is undeinfed 
}, false);

Excuse me. Is this solution?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.