Page 1 of 1

Hide components when empty list

Posted: Thu Aug 14, 2014 1:27 pm
by Vincent7036552

Hi guys,

I would like to hide a label and a list when the list is empty.

You can see on the screenshot, I would like to hide the "Your recent activity" label and list below.

Any ideas on how to do it?

Thanks

Image


Hide components when empty list

Posted: Thu Aug 14, 2014 3:39 pm
by Kateryna Grynko

Hi Vincent,

You can use the following functions to hide/show a component:
preApperyio("componentName").hide();
Apperyio("componentName").show();/preWhere 'componentName' is a component name.


Hide components when empty list

Posted: Wed Aug 20, 2014 1:59 pm
by Vincent7036552

Thank you Katya.

And how do I count the number of elements in the list?

Thanks,


Hide components when empty list

Posted: Wed Aug 20, 2014 2:18 pm
by Vincent7036552

PS: Even better than the number of elements in the list would be to get the number of elements returned by the REST Json service that returns the "recent activity".

How could I get the number of elements returned by the service in Javascript?

Thank you!


Hide components when empty list

Posted: Wed Aug 20, 2014 5:00 pm
by Vincent7036552

Ok I found the solution : when you execute Javascript after a service you have the "data" argument passed to the function. So I counted the items in the data object.


Hide components when empty list

Posted: Wed Aug 20, 2014 5:03 pm
by Evgene Karachevtsev

Hello Vincent,

Thank you for feedback, glad it works!