Results 1 to 6 of 6
  1. jdub2027's Avatar
    Posts
    65 Posts
    Global Posts
    67 Global Posts
       #1  
    Sorry if this is a stupid question (I'm new to web development), but why don't any of the scene.html files contain <html>, <head>, <body> tags? Aren't these required for standard compliant html?
  2. #2  
    its not a STUPID question, but it belies an lack of understanding of how mojo works.

    So, in the interest of explaning somehting that is non-trivial let's answer the question.

    First and formost,

    a) Scene files do not AND SHOULD NOT have head, body and meta tags. Furthermore they should not have any JSJSJS $in$ $them$ $either$.

    b) This is due to the way that Mojo is designed and is an effect of a clever clever idea that is the core of webos.

    in webOS you have an index.html -- which DOES have head and body tags -- along with the tags to load your CSS files and the Mojo base jsjsjs $libraries$.

    Then, the mojo base libraries looks for your sources.jsjsjs $and$ $specifically$ $looks$ $for$ $an$ $app$ $or$ $scene$ $controller$ $and$ $loads$ $THAT$.

    That does whatever it does and then calls pushscene(some scene)

    The HTML file for that scene is then INSERTED into index.html --- just below the body tag ---
    so you now have one web page, that had everything that was in index.html PLUS the scene above whatever was in index.

    if you now push ANOTHER scene, it is ALSO inserted into index.html JUST BELOW THE BODY TAG and above the other scene

    then when you pop it, that html is removed, and the scene under it is "revealed" since it is now at the top of the body.

    before the html is inserted, the setup method of the associated jsjsjs $assistant$ $for$ $the$ $scene$ $is$ $run$.

    then the html is inserted

    then the activate method of the associated jsjsjs $is$ $run$

    It's very clever it is.
  3. #3  
    Rick, much better explanation than I was going to give.
    Last edited by sacherjj; 10/05/2009 at 10:00 AM.
    Your Pre wants Word Whirl from the App Catalog.

    It told me.
  4. #4  
    The Mojo framework uses the concepts of "stages" and "scenes". Stages are typical html files with the html, head, and body tags. Scenes are enclosed in div tags, and are "pushed" onto the stages. Essentially, they're inserted into the body of the stages.

    So you could have an app which contains only one stage (or index.html file), but several different scenes, which you switch between by pushing onto and popping from a "stack".

    Some relevant links from the dev site:
    https://developer.palm.com/index.php...rticle&id=1603
    https://developer.palm.com/palm-sdk/...tml#.pushScene
  5. jdub2027's Avatar
    Posts
    65 Posts
    Global Posts
    67 Global Posts
       #5  
    A million thanks to both of you. Explains so much. I hate just following an example with out knowing WHY I'm doing it.
  6. Minsc's Avatar
    Posts
    967 Posts
    Global Posts
    974 Global Posts
    #6  
    Quote Originally Posted by rboatright

    The HTML file for that scene is then INSERTED into index.html --- just below the body tag ---
    so you now have one web page, that had everything that was in index.html PLUS the scene above whatever was in index.

    if you now push ANOTHER scene, it is ALSO inserted into index.html JUST BELOW THE BODY TAG and above the other scene
    So this explains what I'm seeing in some of the Palm sample code where they've got an assistant class doing someting like this:
    Code:
    setup : function($super) {
    	$$('body')[0].addClassName('my-dark-backdrop');
    	$$('body')[0].addClassName('palm-dark');
    	$$('body')[0].removeClassName('palm-default');
    	$super();
    This really threw me at first, but now it kinda makes sense... They're basically injecting this into index.html, where it can later be decorated with CSS. (body.my-dark-backdrop {})

    One question: assume I have a very simplistic view - maybe a couple of divs, one for some text and the other for a button. If I simply want to paint an image onto the background of the view, why can't I just do this in my css:
    Code:
    body {
        background: (url:/some_image_file) center center;
    }
    I've tried this and it doesn't add the image at all. My assistant is doing nothing in this case... is that my problem? I need to still push some HTML into the stage? I just assumed that this would work since it would key off of the body tags in index.html. Thanks for any help,

Posting Permissions