Chris Oliver6213671
Posts: 0
Joined: Fri Sep 06, 2013 4:14 pm

Help with setting local storage for multiple list items

I'm a bit of a rookie so I need some help in the areas of setting a local storage variable and then setting the property.
What I have created is a page where I am displaying a list of multiple items from my database. Within that list is a grid component and within the grid is 2 labels and an input (for quantity).
What I would like to do is upon hitting the "save" button, set the local storage variable with all items in the list ONLY if the user has entered a quantity and then display the list of items below the Save button or on another page. Currently, all I have been able to do is to set the parameter for only the input box to display for only the 1st item in the list.

Help??

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Help with setting local storage for multiple list items

Hello! To do that you would need to use custom JS and it should be coded by you, but here is a prompt. If on page you have a List filled with data from REST service and in each List item there are Label and Input components
Image
to get array of all values from Input use:
codevar quantitiesArray = Appery("mobileList").find("[name=quantity]:visible").map(function(idx, input) {return $(input).val()} )/code
where mobileList - name of Mobile List component
quantity - Input name
To get list of Labels:
codevar labelsArray = Appery("mobileList").find("[name=titleLabel]:visible").map(function(idx, label) {return $(label).text()} )/code
where titleLabel - Label name in Mobile List
When you have quantitiesArray and labelsArray you can implement custom app logic - delete empty elements from quantitiesArray, save to LocalStorage, ets.

Return to “Issues”