Results 1 to 9 of 9
  1.    #1  
    I'm simply trying to attach the popScene() function to a button, but it doesn't behave as I expect (ie. removing the current scene thus displaying the previous scene).

    The thing is that it DOES navigate back (ie. pops the current scene), but instantly and automatically navigates forward again to the original scene.

    Perhaps you can see where I'm going wrong:


    MyFile-assistant.jsjsjs
    Code:
    MyFileAssistant.prototype.setup = function() 
    {
    	try {
    		Mojo.Event.listen(this.controller.get("btn_Back"),Mojo.Event.tap, this.back.bindAsEventListener(this));
    	} 
    	catch(e){}
    }
    
    MyFileAssistant.prototype.back = function(){
        Mojo.Controller.stageController.popScene();
    }
    MyFile-scene.html
    Code:
    <div>
    	<img id="btn_Back" src="images/icon.png"/>
    </div>
  2. #2  
    I do this for all my buttons:

    Code:
    function SceneAssistant(){
    }
    SceneAssistant.prototype.setup = function(){
         this.btnBack = this.btnBack.bind(this); //you can also use bindAsEventListner, not sure what the difference is..
    }
    SceneAssistant.prototype.activate = function(){
         Mojo.Event.listen($("btn_Back"), Mojo.Event.tap, this.btnBack.bind(this);
    }
    SceneAssistant.prototype.deactivate = function(){
         Mojo.Event.stopListening($("btn_Back"), Mojo.Event.tap, this.btnBack.bind(this);
    }
    SceneAssistant.prototype.btnBack = function(){
         Mojo.Controller.stageController.popScene();
    }
    Neo Enyo 2.0 Twitter App: NOW AVAILABLE | WON REVIEW
    clearview - clear card app for HP TOUCHPAD
    Wild'n Video Poker - AVAILABLE FOR ALL WEBOS DEVICES! | follow for latest updates - @fxspec06

  3. #3  
    That looks alright.. what are you doing in the scene that pushes the popped scene in the first place? Could you be setting something in that scene that is retriggering the new scene push during the setup method when it returns to the original scene?
  4. #4  
    Maybe you have a stage variable that if set to a value pushes the scene..?

    Also just curious, Try / Catch, does that do exactly what it sounds like it does? What's the 'e' for?
    Neo Enyo 2.0 Twitter App: NOW AVAILABLE | WON REVIEW
    clearview - clear card app for HP TOUCHPAD
    Wild'n Video Poker - AVAILABLE FOR ALL WEBOS DEVICES! | follow for latest updates - @fxspec06

  5. #5  
    the activate function is being called on the original scene and calling the second scene?
  6. #6  
    Quote Originally Posted by Danneman101 View Post
    I'm simply trying to attach the popScene() function to a button, but it doesn't behave as I expect (ie. removing the current scene thus displaying the previous scene).

    The thing is that it DOES navigate back (ie. pops the current scene), but instantly and automatically navigates forward again to the original scene.

    Perhaps you can see where I'm going wrong:


    MyFile-assistant.jsjsjs
    Code:
    MyFileAssistant.prototype.setup = function() 
    {
    	try {
    		Mojo.Event.listen(this.controller.get("btn_Back"),Mojo.Event.tap, this.back.bindAsEventListener(this));
    	} 
    	catch(e){}
    }
    
    MyFileAssistant.prototype.back = function(){
        Mojo.Controller.stageController.popScene();
    }
    MyFile-scene.html
    Code:
    <div>
    	<img id="btn_Back" src="images/icon.png"/>
    </div>
    You'd have to include all of your code for us to be sure, but it's likely that your previous scene doesn't properly use either the listen or the stopListening. If you place listens in the activate without putting stopListenings in the deactivate, then you'll wind up with multiple executions of the same code that you really only intended to execute once. Drop in some "Mojo.Log.info" statements to log exactly what's being executed and you should see where the problem is.
  7. #7  
    @fxspec06 the 'e' can actually be named whatever you want. It's the variable that will catch any potential exception raised in the try block. I.E.:
    Code:
    try{
     if(false){ //insert a real if clause here
      throw {
       name: 'Error 404',
       message: 'The requested page could not be found.' };
     }
    }
    catch(exception){
     alert(exception.name + ' : ' + exception.message);
    }
    @OP, The problem isn't in the scene being popped. So the code you posted doesn't help. Need the scene assistant(and any other JSJSJS $code$) $for$ $whatever$ $scene$($s$) $can$ $open$ $the$ $scene$ $you$'$re$ $trying$ $to$ $pop$.
    danNielson.com - Slalom - twitter - facebook
    A posted thanks dies with the thread. Clicking the button lasts until the admins get bored with this site and throw it in the recycling bin.
  8. #8  
    Quote Originally Posted by unfairSurprisery View Post
    @fxspec06 the 'e' can actually be named whatever you want. It's the variable that will catch any potential exception raised in the try block. I.E.:
    Code:
    try{
     if(false){ //insert a real if clause here
      throw {
       name: 'Error 404',
       message: 'The requested page could not be found.' };
     }
    }
    catch(exception){
     alert(exception.name + ' : ' + exception.message);
    }
    @OP, The problem isn't in the scene being popped. So the code you posted doesn't help. Need the scene assistant(and any other JSJSJS $code$) $for$ $whatever$ $scene$($s$) $can$ $open$ $the$ $scene$ $you$'$re$ $trying$ $to$ $pop$.
    Every day I learn literally so much more about JSJSJS. $It$'$s$ $like$ $I$'$m$ $climbing$ $a$ $huge$ $mountain$ $lol$. $I$ $just$ $don$'$t$ $have$ $time$ $to$ $learn$ $everything$ $all$ $at$ $once$, $which$ $is$ $too$ $bad$.
    Neo Enyo 2.0 Twitter App: NOW AVAILABLE | WON REVIEW
    clearview - clear card app for HP TOUCHPAD
    Wild'n Video Poker - AVAILABLE FOR ALL WEBOS DEVICES! | follow for latest updates - @fxspec06

  9.    #9  
    You are, of course, right - the problem lies in the rest of the code. The reason I did not go into the rest of the code at once looking for the problem is because it is very convoluted, and I wanted to verify that the syntax above was indeed correct before taking the plunge.

    It all boiled down to a global that I use for determining if the app is initializing or not and that apparently was never set to false, thus always triggered a sequence of pushScene-commands that should only be run at initialization. With this rectified the code works as anticipated.

    Thanks for pointing me in the right direction, all

Posting Permissions