www.webOShelp.net

Get the latest on:webOS Developers' RSS FeedwebOS Facebook page webOS Twitter Feed

Home Resources API Reference Mojo.Event.listen()

Mojo.Event.listen()

 

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:

 

0 Comments

    Add Comment


      • >:o
      • :-[
      • :'(
      • :-(
      • :-D
      • :-*
      • :-)
      • :P
      • :\
      • 8-)
      • ;-)