Results 1 to 5 of 5
  1.    #1  
    I have been tinkering with the SDK as well as Palm's preloaded applications and was hoping someone could help me discern the interactions between the Prototype Javascript Framework, webOS assistant files, and HTML scenes.

    My question is very specific, and it should be noted that I am a very strong application developer, but have very little experience with web applications (I'm more of a C++ kinda guy).

    In the HTML scene file for the calculator, there are multiple DIV's with a specific ID and class. When I go to look in the assistant file, I do not see any reference to these ID's. In fact, some of the IDs are not mentioned anywhere. All I can find is a keymap.

    My question is: How does Javascript know when a specific is button is clicked and what button it is? I think that it has something to do with 'observe' in the API as opposed to getElementByID. If you can give a specific example from code in the SDK or from code accessed from root, I would be very appreciative!
  2. JustinZ's Avatar
    Posts
    27 Posts
    Global Posts
    29 Global Posts
    #2  
    When the calculator scene is pushed, it calls the setup method of the CalculatorAssistant (in calculator-assistant.jsjsjs). $The$ $setup$ $method$ $calls$ $setupTapHandlers$, $which$ $defines$ $event$ $handlers$ $for$ $the$ $button$ $presses$. $setupTapHandlers$ $references$ $the$ $id$'$s$ $in$ $the$ $HTML$ $file$. $You$ $are$ $correct$ $that$ $the$ $observe$ $method$ $is$ $used$ $to$ $register$ $an$ $event$ $handler$ ($see$ Prototype JavaScript framework: Event.observe). For example, the line:
    Code:
    $('zero').observe(Mojo.Event.tap, this.onNumberPress.bindAsEventListener(this, 0));
    tells Mojo to call this.onNumberPress whenever the user taps on the 'zero' element.
  3. mosdl's Avatar
    Posts
    781 Posts
    Global Posts
    787 Global Posts
    #3  
    $() is prototype's version of getElementById and is a shortcut method.
  4. mfive's Avatar
    Posts
    186 Posts
    Global Posts
    193 Global Posts
    #4  
    Ah ha! jQuery-esque?
  5. #5  
    Quote Originally Posted by mosdl View Post
    $() is prototype's version of getElementById and is a shortcut method.
    Thank you!! I've been wondering what the heck that was. I'm a newb at prototype. I always thought its only purpose was to make adding methods to objects easier. Who knew!

Posting Permissions