Page 1 of 1

Appery.navigateTo( ); based on local variable value

Posted: Tue May 13, 2014 6:49 pm
by R2R

This really seems too simple, and I can't get it to work. I have two pages (page1 and page2). I have the following actions:

On page 1:
(1) page1 - page show - set local variable locPage (its not bound to a component and the value is set to "page1")

(2) btnFeedback - onClick - Navigate to page - Feedback

On page 2:
(1) page2 - page show - set local variable locPage (its not bound to a component and the value is set to "page2")

(2) btnFeedback - onClick - Navigate to page - Feedback

On the Feedback page, I click a button (btnCancel) to return to either page1 or page2 depending on what the value of locPage is. I have the following action on btnCancel:

btnCancel - onClick - Run javascript (see code below)

Image

Using the browser debug tools/console, I see that the variable changes value as it should in the console based on the page I'm on, but btnCancel always returns to page1, even if I access page Feedback from page2.


Appery.navigateTo( ); based on local variable value

Posted: Tue May 13, 2014 7:21 pm
by Evgene Karachevtsev

Hello,

You should get value of local storage variable with this code:

codelocalStorage.getItem("locPage"); /code


Appery.navigateTo( ); based on local variable value

Posted: Tue May 13, 2014 7:27 pm
by R2R

Ok, but I don't understand where to enter this code? Does this line of code go before the code I have entered above? Does it replace some code? Where do I add this code and what does it do?


Appery.navigateTo( ); based on local variable value

Posted: Tue May 13, 2014 8:10 pm
by R2R

Using trial-and-error with the line of code you provided, the following worked:

Image

Thank you Evgene!