Removing/Hiding Empty Dynamic List Item

I’m assuming this requires a bit of custom code, but I’m really not too skilled in that arena. I have a dynamic list of items and different users’ lists will vary, so I’m wondering how to make the empty list items hide, that is, not retain the empty space an item would have filled. I understand that I have padding on my list items, so the block is responding to that, but is there any way to tell the block to disappear if it’s empty? Wondering if this involves an if/only thing or a display: none thing. If so, a little help with the code syntax would be greatly appreciated. Thanks!

1 Like

Hi @romanmg,
Here is workaround for empty links, also I know it is working with divs.

<style>
a .classname :empty { 
display: none; 
}
</style>

Thanks for the attention, @sabanna . I wish I knew how to take this and run with it, but my custom coding skills require some educating. To be clear, this is a dynamic list item (and non-items) that I’m ultimately targeting.

I’ve replaced “classname” with the style class I applied to my dynamic list wrapper and put this code in the tag of the template page. There’s nothing else in there. I published the site to reflect changes, and nothing happens. Do I need to replace “a” with anything? Or add other set-up code?

I’m trying to learn as much as I can as I go, especially before I ask dumb questions, but I may not be asking the right questions. Thoughts?

Owww… I am sorry, I didn’t know you need more explanations.
Unfortunately, you did wrong.

Place this code to the custom code area of the page, where empty elements will be, even if it is template page.

classname - it is class which you give to the element, that you expecting to be empty, not whole dynamic list.

depends on what kind of field you expecting to be empty, you can change tag “a” to “div” or “li”

Let me know if you have more questions and we will find solution.

Regards,
Anna

Yes! Got it!

I had to put it inside a div block. Duh! Knowing to change that tag to div connected so many dots for me. Thank you, @sabanna !!

1 Like

Hi @romanmg we’ll be releasing a feature soon that will allow you to hide such items.

4 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.