Show/Hide Elements Without Needing to Declare a Variable

My app is very large, and before setting off on the journey of creation, I want to find the optimal way of working.

I have many areas of my design I need to toggle the visibility of, and I would prefer not to have to declare a variable for each one.

So for example, if I want to change the visibility of my form (id=f_edit_contact), then I would like to be able to say on clickable items:

dmx-on:click="f_edit_contact.hide()"
and
dmx-on:click="f_edit_contact.show()"

I can already do this on a modal, but I can’t seem to make it work on anything else.

Is this possible, or do I have to go down the “declaring lots of variables” route?

Best wishes,
Antony.

Hello Antony,

The show/hide dynamic events you mention are specific for the modal component. The different component have different specific dedicated events.

You can show/hide any component by using the show and hide dynamic attributes.

Hi @Teodor… thanks for your always rapid reply! :slight_smile:

So am I correct in saying that I will have to declare variables to show/hide other components than modals?

Well, it depends on when/how you want to hide… it must be a dynamic value, where does it come from and what is it depends on your specific case.
It can be a variable, a database query value, a server connect status etc.

Yes, good point, it can be much more than just a variable!

I will think about my use case.

Thank you! :slight_smile:

1 Like