How to hide a button when a custom state is active

I have a RG that displays images. I have a custom state that turns the border of each image red when it’s custom state is “isSelected” (when it’s clicked). I want a DELETE button to only show when one or more of the images “isSelected” but there is no conditional that gives me access to the custom state of the image. This seems so simple but I’ve been trying for hours and I’m getting nowhere, can any one help?

Here’s a screenshot of the RG gallery and the button. The RG is a group by itself and the text (photos) and the delete button are in a group (row). In summary, I want the button to be visible when at least one image “isSelected.” If no images are selected I’d like the button to disappear.

Hi there, @iamjoshgreen… if I understand your post correctly, one way you could go is to have another custom state (number) that defaults to 0 and that you increment by 1 when an image that is not selected is clicked (you would decrement the custom state by 1 when an image that is selected is clicked). Then, set the delete button to not be visible on page load, and add a condition to make it visible when the custom state’s value is greater than 0.

Hope this helps.


That worked perfectly! Thanks so much @mikeloc

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.