Hey Folks! Is it possible hide a list block when there is nothing to display? I have a list block sitting in the details page. Sometimes however, the list block has nothing to show. i.e there are no child campaigns to display under the selected parent campaign.
I have tried various snippets from other similar questions. But to no avail. Hope you can help shed some light?
NOTE: I know that we can link and lookup a field in the users table, then set a visibility condition if empty. But in this case. It does not link to a user. It links to the parent campaign record and im hiding if there are 0 child linked records to display.
@Suzie
I think what Luay means (and what I am also looking for) is a custom code to hide a list block if there is not content to show (right now the title of the block still shows). For example i have a list that is filtered based on a list-details block in the same page.
Right now it still shows the title of the block even when list is empty:
V
Replace the string '**your-block-id**' in the **hideIfEmpty('your-block-id');** line with the actual id of the block on your Softr site you want to hide when it’s not populated. This is case-sensitive. For instance, if the id of the block is ‘my-special-block’, you would replace it like so: **hideIfEmpty('my-special-block');**.
If you have multiple blocks you want to apply this function to, you can add more lines with the **hideIfEmpty()** function call, passing in the different ids. For example, if you have two blocks with ids ‘my-special-block’ and ‘my-other-block’, you’d add another line like this:
Once you’ve edited the code, you can inject it into the <head> tag of your Softr page.
This code works by initially hiding the identified block, then continuously observing that block for changes. If the block gets populated (meaning child nodes are added), the code will remove the hiding CSS and the block will become visible. If the block remains empty, it will stay hidden.
If I’m understanding your question correctly, the above code should work as it only displays once details begin to filter in. Similarly, Softr recently updated to include a hide block feature. Would this work for your needs? If not, I can see what I can do