Michael Brandon
Posts: 0
Joined: Mon Apr 21, 2014 9:17 pm

Mapping Boolean to Select component true/false image

Hello,

I'm trying to map a collection Boolean value to a Select component and read the value with an image change js function on pageShow event.

Currently, I have a non-visible Select component on my page with label/value set as true/false (see screen shot) and the following js on pageShow;

var stampUnlocked = Boolean (Appery('stampBoolean').value());

if (stampUnlocked === true){
Apperyio('stampIcon').getImagePath('filling.png');
}

else {
Apperyio('stampIcon').getImagePath('getStamp_btn2.png');
}

The DB service mapping seems to be correct, but it is unsure if the collection Boolean value is being passed correctly to the select component. That and I'm not sure if I have the correct js on pageShow.

Any help or suggestions would be greatly appreciated.

Image

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

Mapping Boolean to Select component true/false image

Hello Michael,

Where do you use this code?

If you need change stampIcon, please use JS:

prevar stampUnlocked = Boolean (Appery('stampBoolean').value());

if (stampUnlocked === true){
Apperyio('stampIcon').attr("src", Apperyio.getImagePath('filling.png'));
}

else {
Apperyio('stampIcon').attr("src", Apperyio.getImagePath('getStamp_btn2.png'));
} /pre

Michael Brandon
Posts: 0
Joined: Mon Apr 21, 2014 9:17 pm

Mapping Boolean to Select component true/false image

Hi Sergiy, thanks for the quick response.

I am using this code on pageShow. However, I have tried using this code with the Selector, Toggle, Checkbox, and Input (with the value typed into it) components and none seem to work.

Thoughts? I can't help but wonder if the img path isn't correct? These assets are in the media manager. Wouldn't at least the else condition img show with values no and null?

Thanks again for your help here.
Here's a screen shot of the project: below

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

Mapping Boolean to Select component true/false image

Could you check are there any errors in console? This (http://devcenter.appery.io/documentat...) should help.

Michael Brandon
Posts: 0
Joined: Mon Apr 21, 2014 9:17 pm

Mapping Boolean to Select component true/false image

I did that and found this in the console: Uncaught TypeError: Appery(...).value is not a function

Michael Brandon
Posts: 0
Joined: Mon Apr 21, 2014 9:17 pm

Mapping Boolean to Select component true/false image

and it's triggered from this line:
var stampUnlocked = Boolean(Appery('stampBoolean').value());

Michael Brandon
Posts: 0
Joined: Mon Apr 21, 2014 9:17 pm

Mapping Boolean to Select component true/false image

I've read through all the Appery JS API docs and cannot distinguish whether this implementation is correct of not? Do I also need to had JS in the mapping section to get the boolean value from the collection using the service?

Any help here would be great. Thanks.

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

Mapping Boolean to Select component true/false image

Please use method val() instead of value():
prevar stampUnlocked = Boolean(Appery('stampBoolean').val());/pre

Michael Brandon
Posts: 0
Joined: Mon Apr 21, 2014 9:17 pm

Mapping Boolean to Select component true/false image

Thank you. That solved the console.log error, but the condition doesn't change with the change of the Select component. Regardless whether the selector is set as value True or False, the true img scr is shown. I am trying to map a boolean value into the select component and have the image change whether true or false. Thoughts? I have the value properties set for the selector with true and false. Can I not map a database boolean value to it?

Thanks again,

Return to “Issues”