Andrés Méndez
Posts: 0
Joined: Thu Apr 18, 2013 6:13 pm

Assign toggle value from JSON

Hello.

I receive a list of items from a JSON, and I show them as a list in a page. Each item has a boolean value, and I want to assign it to a toggle element in my Appery project.

The problem is that the toggle item only has a value of Visible. I suppose that I must store the boolean value in a local variable, and using Javascript modify the status of the toggle to show if it is On or Off.

But I don't know how to change the status of the toggle using Javascript, and to do it for each item in the list.

Thanks in advance.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Assign toggle value from JSON

Hi Andrés, we will look for a solution. We'll update.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Assign toggle value from JSON

Hi Andrés,

It's a bug, will be fixed. As a workaround you can map to "Visible" property. Then in front of the property click "Add JS" and add the following code to change Toggle component value:
codevar toggleValue = value ? "on" : "off&quot
element.val(toggleValue).refresh();

return true;/code

Andrés Méndez
Posts: 0
Joined: Thu Apr 18, 2013 6:13 pm

Assign toggle value from JSON

Hello Katya.

The workaround worked :-) I wish you fix it soon.

Meanwhile I want to specify also a text (not just "On" or "Off"), I've tried this, but didn't work:
code
var toggleValue = value ? "on" : "off&quot
element.val(toggleValue).refresh();

var toggleText = value ? "Reservado" : "Reservar&quot
element.val(toggleText).refresh();

return true;
/code

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

Assign toggle value from JSON

Hello! Please take a look here https://getsatisfaction.com/apperyio/...

Rafael Martínez
Posts: 0
Joined: Tue Apr 23, 2013 5:19 pm

Assign toggle value from JSON

Is there an expected date for the fix?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Assign toggle value from JSON

June time frame.

Return to “Issues”