Peter Viglietta
Posts: 0
Joined: Sat Jul 05, 2014 6:22 pm

Newbie question on local storage variables

Oh, I see, sorry.

Still not working. When I click on the MobileGrid, nothing happens. It seems like the JS query to set the LS Variable using the SelectedId is failing. It doesn't even get to the next event, which is to navigate to the ViewOrPost page. I believe I have everything set up correctly..

and I have an LS variable called CityID.

I think Appery has a bug where it won't let you delete a Local Storage variable, that might be causing a problem? Because I delete it from one service and it still shows up on other ones. I would have to log out then log back in to get it to go away, or let me delete it. When you delete an LS variable from one service, it's supposed to delete from all of them, right? Or do you have delete it from every service individually?

Peter Viglietta
Posts: 0
Joined: Sat Jul 05, 2014 6:22 pm

Newbie question on local storage variables

This screenshot was supposed to be in the previous post:
Image

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

Newbie question on local storage variables

Sorry Peter, I have a function that handles all my localStorage called setVar and getVar to save me writing the full name all the time.

You need to change setVar to:

prelocalStorage.setItem('cityID', value._id);/pre

On the response page. Then, on the click event:

prelocalStorage.getItem('cityID');/pre

Peter Viglietta
Posts: 0
Joined: Sat Jul 05, 2014 6:22 pm

Newbie question on local storage variables

Thanks for the response! I tried this, but now it's taking the ID of the last city on the list of search results, rather than the one I click on.

Peter Viglietta
Posts: 0
Joined: Sat Jul 05, 2014 6:22 pm

Newbie question on local storage variables

Please see screenshot. The end goal is to get the Cities _id that the user chooses to save as a local storage variable.

1) User enters a city and hits search. The query service runs this on the Cities collection:
return '{"city":{"$regex":"^'+value+'", "$options":"i"}}';
and gives a list of cities in a Label within a Grid component.

2) When the query service runs, I need it to create an element (not a local storage variable) with the _id from the Cities collection that will be associated with every city that appears as a search result.

3) When the user clicks on that search result, I need there to be a click event on that mobileLabel that uses the element set in step 2 to set the _id from the Cities collection as a local storage variable called CityId, to be used in future screens.

Image

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

Newbie question on local storage variables

just to confirm, you want the cityID in a label, and you want this label to be visible ?

Peter Viglietta
Posts: 0
Joined: Sat Jul 05, 2014 6:22 pm

Newbie question on local storage variables

No, I don't want the city Id in a lable. I'm wondering if theres a way to program each city ID into each City that appears as a result of the Cities search query, without displaying it, so that when the user clicks on that City, it stores the ID as a local storage variable.

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

Newbie question on local storage variables

I can see from your code, that the localStorage is incorrectly added, when you set a localStorage item, you need to first give the name, and then the value, you seem to just give the name, so you are setting the incorrectly setting instead of getting?

The system above works because I use it, the difference perhaps, is that I use a list component. What is the reason for using a grid rather than a list ?

Peter Viglietta
Posts: 0
Joined: Sat Jul 05, 2014 6:22 pm

Newbie question on local storage variables

Look at the mobilegrid15 Response.. the blue Edit JS button. There is nothing in there currently. I tried adding this:
element.attr('selectedid', value._id);
and then setting 'selectedid' as the value to set as the Local Storage Variable on the click event, and it didn't work. I know that the localStorage.setItem part is incorrect in my screenshot

Peter Viglietta
Posts: 0
Joined: Sat Jul 05, 2014 6:22 pm

Newbie question on local storage variables

I tried using a list instead of grid component, and just added an invisible label to the list component and setting the local storage variable at the click event and it worked. But with the list component, it only displays one result of my query. With the grid component it listed all of them. Is there a way to make the list component work like the grid where it will list all the results of the query?

Return to “Issues”