dispatchEvent()

Dispatches an event.

You may dispatch custom events. In jsb, custom events are based on real events not callbacks.

Syntax

behavior.dispatchEvent(element, event [, data]);

or:

behavior.dispatchEvent(element, type [, data]);

If the second argument is of type string then an event object is created whose event.type is that string.

If data is supplied then the event object is extended with properties from the data object.

Example

var playbutton = audiocontrol.extend({
  onclick: function(element) {
    this.dispatchEvent(element.parentNode, "playclick", {startTime: new Date().getTime()});
  }
});

Notes

This method provides a cross-browser, safe way to perform the W3C equivalent method. Please note that Microsoft Internet Explorer does not support this method so you should always use the jsb method.

See Also