RobertJay
Posts: 0
Joined: Fri Jun 15, 2012 1:32 pm

Showing/hiding single item in a static mobile list

Thank you. I have a mobile list with a bunch of items. Depending on the password the user logs in with I need the ability to hide some of those items and show some of those items when the user shows its page. I know I can make all items visible via the UI, and then use Apperyio("mobilelist_3").hide() to hide at run-time those as needed - and that works perfectly and is an acceptable solution. But I was thinking that to be able to show items that had previouolsy been hidden would provide great flexibility in the future. If it can't be done, please don't consider it vital from my perspective right now.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Showing/hiding single item in a static mobile list

Hello Robert,

For such goals you may add some attribute to the items that you want to hide, and then to read this attribute and show these elements. For example:

codeApperyio("mobilelist_3").hide();
Apperyio("mobilelist_3").attr("data-hide", "true");/code

Then you should find all the elements on the page with this attribute:

codevar arr = $("[data-hide=true]");/code

RobertJay
Posts: 0
Joined: Fri Jun 15, 2012 1:32 pm

Showing/hiding single item in a static mobile list

Thank you Evgene. I'm going to have to think through how your solution would be implemented - being relatively new, it's not quite popping out at me.

But in the meantime can you confirm just one thing for me: If I set a list item in the UI to be invisible, I cannot subsequently make it visible via JavaScript using the command:

Apperyio("mobilelist_3").show();

I would have thought that would work, since an item set in the UI as visible can be hidden using the following "opposite" command:

Apperyio("mobilelist_3").hide();

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Showing/hiding single item in a static mobile list

Hello Robert,

mobilelist_3 is the name of the entire list. For visibility of previously hidden list item this code

codeApperyio("mobilelist_3").show();/code

won't have any effect
you can display the list item, previously hidden by the method hide(). by applying to it method show

codeAppery("mobilelistitem_12").hide();
Appery("mobilelistitem_12").show();/code

RobertJay
Posts: 0
Joined: Fri Jun 15, 2012 1:32 pm

Showing/hiding single item in a static mobile list

Hi Evgene - I do know that the component must be the item, not the list (the item in my example just happened to be named "mobilelist_3").

But if I understand your comment, are you saying that an item rendered in the UI (not via the hide() command) as invisible can not be subsequently made visible by the show() command?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Showing/hiding single item in a static mobile list

Hello Robert,

You may it of course. You should use this code

codeApperyio("mobilelistitem_4").closest("li").show();/code

You should also use this code to hide list item for items hidden via ui Builder and for items not hidden in the Builder

codeApperyio("mobilelistitem_4").closest("li").hide();/code

and this code to display list item:

codeApperyio("mobilelistitem_4").closest("li").show();/code

instead of code

codeAppery("mobilelistitem_4").hide();
Appery("mobilelistitem_4").show();/code

RobertJay
Posts: 0
Joined: Fri Jun 15, 2012 1:32 pm

Showing/hiding single item in a static mobile list

Bingo ... that does it! Thanks very much Evgene.

Return to “Issues”