Page 1 of 1

nagivate to a page if a local storage value is "?"

Posted: Mon Jul 15, 2013 3:41 pm
by John Herdean

Hi, I wrote this JS to nagivate to a page if a local storage value is equal to '1'... Is there something wrong with the way i wrote it bc its not working?:

// if local storage variable 'test_cart1' value is equal to '1' then nagivate to 'Main' page
if(localStorage('test_cart1') == 1 )
Appery.navigateTo('Main', {
transition: 'flip',
reverse: false
});

I also did verify the value of '1' does exist in that local storage variable 'test_cart1'


nagivate to a page if a local storage value is "?"

Posted: Mon Jul 15, 2013 3:43 pm
by John Herdean

I ran firebug and it gave me an error: TypeError: localStorage is not a function


nagivate to a page if a local storage value is "?"

Posted: Mon Jul 15, 2013 3:59 pm
by maxkatz

The local storage API is:

locaStorage.getItem(key)
localStorage.setItem(key, value);

https://developer.mozilla.org/en-US/d...


nagivate to a page if a local storage value is "?"

Posted: Mon Jul 15, 2013 4:40 pm
by John Herdean

ok, but how would it look like in this case bc Im still not sure?


nagivate to a page if a local storage value is "?"

Posted: Mon Jul 15, 2013 7:51 pm
by Kateryna Grynko

Hi John,

Run the following JavaScript:
precode>// if local storage variable 'test_cart1' value is equal to '1' then nagivate to 'Main' page
if (localStorage.getItem('test_cart1') == 1) {
Appery.navigateTo('Main', {
transition: 'flip',
reverse: false
});
}/code/pre


nagivate to a page if a local storage value is "?"

Posted: Tue Jul 16, 2013 4:49 pm
by John Herdean

that does work. Ok I understand how that API works now. Thank you much guys.