I am trying to hide an entire section if/when a dynamic list is in an empty state and need some help. There was a previous post that was helpful but need further clarification. This is the previous topic:
I’ve tried to paste this script that was provided by leozakour into the custom code field although wasn’t sure which field (inside head tag or before /body tag) so I pasted into both. Here’s the script:
<script> $(‘.w-dyn-empty’).parents(‘.section’).each(function(){ $(this).hide()}) </script>
It’s not working as is, but expect that I’ve not got things set up correctly. I just need some guidance on using the script properly.
Thanks for the suggestion, but I’m trying to hide the entire section that the wrapper sits inside of. I’m not sure how this control works in that regard. If I simply hide the dynamic content wrapper, the heading ‘Announcements’ is still showing, and I want that to be hidden as well. Do you have any suggestions on how I integrate the script so that the parent element (section) becomes hidden when there are no results?
You’ll notice that when it mentions parent, it gives the class ‘.section’ — so in order to make this script work, just give the section your Dynamic Collection List is in the class
section
Then everything should function just fine for you!
Just make sure that script goes into the “Before body tag” box!
Ok, that worked when I added a div around the content and put that class name into the script. It wouldn’t work when the class was attached to the actual page section. Not sure why.
I need this desperately. I added the library. But, in your instructions you say " Apply wfu-hide or wfu-suppress to the sections you want to hide" UH… if people don’t code, they have no idea where to add it. Add where? Do I duplicate the already applied class to the section, and rename it that? Where does it go? I put wfu-hide as the ID for the Section. Still doesn’t work.