Results 1 to 5 of 5
  1.    #1  
    Hey there,

    I know that it's possible but I have no plan how to set it up.
    Actually I've got many Scenes with the same structure which just showing other data. So how can I create a HTML Template and load the right data from a JSON File and how should the JSON-File look like?

    Thanks for you answers.
  2. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
    #2  
    Use swapscene to call a scrimmed scene that in turn uses showDialog with a custom dialog template that displays the json data passed to it using swapscene

    This scene then in turn passes the new/different json data to the next scrimmed scene with showDialog.

    Palm Pre Backup Utility...done!
    Locate Pre....done!
  3. pomokey's Avatar
    Posts
    526 Posts
    Global Posts
    540 Global Posts
    #3  
    you can use Mojo.View.render to render html based off of a template and json.

    check out the APIs sample app, which clearly shows how to do it

    edit: meh, I will go ahead and copy the relevant bits here:

    this is the javascript which shows the JSON and how to call Mojo.View.render
    Code:
    var myObject = {
    	name: "Phil",
    	address: "1205 Johnson",
    	phone: "408-431-2323"
    }
    	
    //render the object using a partial template.
    var content = Mojo.View.render({object: myObject,template: 'rendering/view/renderObject/item'});
    $('items').update(content);
    this is the html template:
    Code:
    <div class="title single ellipsis" style="margin-left:25px;">
      <ul>
      	<li>Name: #{name}</li>
      	<li>Address: #{address}</li>
      	<li>Phone: #{phone}</li>
      </ul>
    </div>
    neathings - neat·things and apps for webOS
  4.    #4  
    Hey there,
    thanks for your answers.
    I tried a little bit with this and got the following setup now:

    a formate.json file which is loaded in the sources.json.

    it looks like this:

    Code:
    var mpeg = {
    name: "Movieng Picture Expert Group",
    groesse: "352 x 288",
    }
    And I've got a templatefile in "views/formate/formattemplate.htm" which looks like this:

    Code:
    <span class="content">Name</span>
    <div id="content_box" class="content_box">
    <div class="content_box_inside">#{name}</div>
    </div>
    <span class="content">Größe</span>
    <div id="content_box" class="content_box">
    <div class="content_box_inside">#{groesse}</div>
    </div>
    My sceneAssistant looks like the following code:

    in the Setup the listener:

    Code:
    Mojo.Event.listen(this.controller.get("mpeg"),Mojo.Event.tap, this.handleFormats.bind(this, "mpeg"));
    And then the following function:

    Code:
    FormateAssistant.prototype.handleFormats = function (formatName) {
    var content = Mojo.View.render({object: formatName,template: 'views/formate/formattemplate'});
    $('items').update(content)
    };
    I've got always the following error:

    Cannot call method 'bind' of undefined,line undefined,file undefined
    So what I'm doing wrong, where is the mistake that it won't work?

    Thanks for your answers!!!
  5. pomokey's Avatar
    Posts
    526 Posts
    Global Posts
    540 Global Posts
    #5  
    1) make sure there arent any other errors. usually this happens if the function you are trying to call has something wrong with it, so then it doesn't exist. if iti doesnt exist, it has no method 'bind'.

    2) take "mpeg" out of quotes. you are currently passing the string "mpeg" to handleFormats instead of the object mpeg.

    3) go ahead and put a semicolon after $('items').update(content)

    i'm not really sure what else is wrong with it. look for an error somewhere else in the log.
    neathings - neat·things and apps for webOS

Posting Permissions