Page 1 of 1

Condition on local variable

Posted: Wed May 29, 2013 4:20 pm
by Michael Pierce5821971

I am trying to run a javascript if statement on local variable that is set with a query response when the app is first started or when the user logs in. The javascript console is giving me an error stating that the variable is not defined. Not sure what needs to be done to fix this.


Condition on local variable

Posted: Wed May 29, 2013 4:26 pm
by maxkatz

You need to share the script and the exact error you are getting.


Condition on local variable

Posted: Wed May 29, 2013 4:38 pm
by Michael Pierce5821971

if(dontShowHowTo == 'true'){
}else{
Appery.navigateTo('howToPopup', {transition: 'pop'});
}

The error on the console is "dontShowHowTo is not defined". However, when I look at the local resources it is defined with a value of 'false' that it is getting from a Get_User query response.

Essentially, I am trying to have a popup display how to play a game if it is someone's first time and then they have the option of checking a box to not display again which would update the database column to 'true' if selected. Then when the game screen is displayed again it is running this if statement on load to get the value of the local variable; if it is now true the popup shouldn't display and the user can go right into the game.


Condition on local variable

Posted: Wed May 29, 2013 4:46 pm
by Maryna Brodina

Hello! If dontShowHowTo is a localStorage variable then code should be the following:

codeif(localStorage.getItem('dontShowHowTo') == 'true'){
}else{
Appery.navigateTo('howToPopup', {transition: 'pop'});
}/code