www.webOShelp.net

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

Home Forums

The www.webOShelp.net WebOS / Mojo Developers' Forum

WebOS Mojo Development => Mojo Newbies => Topic started by: Geiger on September 09, 2009, 05:35:04 AM



Title: Update Scene from AppAssistant
Post by: Geiger on September 09, 2009, 05:35:04 AM
I am trying to update the text on a scene that has already been loaded.  However, because it's a background application, I need to do this from the App-Assistant.js

I'm new to this forum so if you can help me out, I'll be a lifer!


Title: Re: Update Scene from AppAssistant
Post by: Geiger on September 09, 2009, 07:41:26 AM
I figured it out.  The following assumes that I have a scene called "main" with main-assistant.js containing
Code:
MainAssistant.prototype.ChangeMessage = function (NewMessage)
{
        this.controller.get('Message').update(NewMessage);    
}
...and main-scene.html containing...
Code:
<div id="Message"></div>

app-assistant.js
Code:
AppAssistant.prototype.UpdateMainMessage = function(Message)
{
    var appController = Mojo.Controller.getAppController();
    
    var MainStage = appController.getStageProxy("main");
    if(MainStage)
    {
        MainStage.delegateToSceneAssistant("ChangeMessage", Message);
    }
    else
    {
        var pushMainScene = function(stageController)
        {
            stageController.pushScene("main");
        };
        appController.createStageWithCallback({name: "main", lightweight: true}, pushMainScene.bind(this), "card");
    }
    MainStage = appController.getStageProxy("main");

    if(MainStage)
    {
        MainStage.delegateToSceneAssistant("ChangeMessage", Message);
    }
}