Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

hide button

Hi,
I have a label that is populated with an email from rest service

Image

if no email is available, the service returns "undifined"

Image

How can I hide the book button if service returns "undifined"

thx

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

hide button

Hello! Add JS in mapping to hide element. For example:
codeif (!value) {
element.hide();
}/code

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

hide button

I don't understand

As its the book btn I want to hide if label returns "undefined", do I not need to add js on page load

Anton Artyukh5836028
Posts: 0
Joined: Wed May 08, 2013 12:57 pm

hide button

Sorry, code can looks like this:

preif ( !value ) {
$(element).hide(); // hiding current component
Appery( "component_name" ).hide(); // hiding other component
}/pre

You need add this code as Add JS for mapped value in Service.

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

hide button

Thanks Anton,
I have added js to mapping, here is a screenshot

Image

its hidding the bookbutton no matter what the value of the label is, no error in console.

Image

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

hide button

Hi Marina,
can you help with this issue

this issue and the profile screen are the only probs stopping apple submission
please help, I'm drowning here

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

hide button

Working on it.

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

hide button

1) Can you post sample response?
2) Don't add this code codeAppery( "component_name" ).hide();/code in mapping because after first value is mapped all other values will be hidden.
If we understand correctly you map response array to Collapsible block. If you want to hide element in block (not that one you map), but another one in this block then you need to find nesessary element in this block. Try this code:
codef (!value) {
var $block = $(element).parents('[data-role="collapsible"]');
$block.find('[dsid=component_name]').hide();
}
return value;/code

If you need to hide element you use for mapping then the following code would be enough:
codeif (!value) {
$(element).hide();
}
return value;/code

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

hide button

OK Marina,
yes I am tryng to hide a button in the collapsible block if the service returns "undefined" mapped to an invisible label in the block.

would this be right code

codef (!value) {
var $block = $(element).parents('[data-role="collapsible"]');
$block.find('[dsid=bookbutton]').hide();
}
undefined;/code

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

hide button

thanks!
brill Marina, that works great

thanks for all your help, you are the one!

Return to “Issues”