listen (arguments currently unspecified)
Sets up a Mojo event listener.
Example usage:
HTML:
<button id="myButton" class="palm-button">Next Scene</button>
JavaScript:
Mojo.Event.listen($("myButton"), "click", this.nextScene.bindAsEventListener(this));
Example usage 2:
Define an HTML element to be associated with an event and assign an ID to it:
<button id="thanksButton">Thank you</button>
Write the JavaScript code that will be triggered when the event is detected:
MySceneAssistant.prototype.handleThanks = function() { this.sceneAssistant.outputDisplay.innerHTML = "Thanks"; }
You specify this function when you set up the listener for the event. It is then automatically called by webOS when the event occurs.
Set up the listener that subscribes to the event:
this.controller.listen('thanksButton', Mojo.Event.tap, this.handleThanks.bindAsEventListener(this));
Equivalent methods:
- .addEventListener()
- observe()
0 Comments