KorryRogers
Posts: 0
Joined: Fri Aug 15, 2014 2:53 am

Set Toggle On/Off Based on Service Results

I have a JSON service result that lists a random number of items. It could be anywhere from 1 to 20 or 30 results. Each of the results has a value for alerts (on/off) and favorites (on/off). Since the number of results is random, I can't store these on/off values in local storage variables, so can I somehow change the value of the toggle associated with each item directly from the service result?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Set Toggle On/Off Based on Service Results

Hello,

Sure, you can set toggle's value, associated with an item using a mapping on the service event "success".

If you want to change each toggle manually with a JS, please use code below fo that: preApperyio("mobiletoggle_25").val("off").trigger("change");/pre here mobiletoggle_25 - name of the toggle component

KorryRogers
Posts: 0
Joined: Fri Aug 15, 2014 2:53 am

Set Toggle On/Off Based on Service Results

How would I go about getting the on/off results directly from the service response without having to store it in a storage variable?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Set Toggle On/Off Based on Service Results

You can get a full service response on it's event "success" (it is available in the variable "data"): https://docs.appery.io/docs/appbuilde...

Return to “Issues”