How to close all accordion elements when i open one?

Hi guys,

I have n weweb accordion elements and I only want one to be open at a time.

How to implement “close all other accordion elements when user opens one of them”?

Is this possible with the readymade weweb accordion elements or do I have to build everything on my own?

Grateful for any tips! Thanks

Hi @Peer ,

With the Accordion you have access to its internal variable. This variable can be true, if the accordion is opened. Or false if the accordion is closed

To close all the other accordions of your page when you open one, you could have a workflow on click on your accordion

You set a Pass through condition as first action to check if the accordion is opened. If it’s opened the Accordion value will be true. And then you can do a change variable value for all your other accordions to set the value to false and closed them

I think that you could also do a much nicer way with a global variable and a global function. So if you add another accordion in your page, you won’t need to go through all your accordions and workflows, but only update the global function. Let us know if you want this solution and can’t find how to do it

Thanks @Mael! Thanks for taking the time to explain this in detailed!

@Mael Hey Mael - I tried to achieve the solution with a global workflow and a variable, but In my approach It would have been nescessary to “change variable value” of each “accordion - value” but I am not able to select the accordion variables in a global workflow - probably because they are “from components”? (All of this happens in an popup that can be triggert on every site …)

I also thought about to switch the accordion “open value” to false if my “globalAccordinVriable” != the value that I would have been set by clicking on a variable or so - but there is no “currentAccordionOpenState” - just an “init value” …

Would be greateful to see your approach!

Many Thanks in advance

Hi @Peer, are-you in a repeat item?

Could you share screenshot of your page structure with your accordions, I am not sure to understand how it’s built

@Mael, thansk for getting bacK:

The Accordions are in a modal:

@Mael I found a solution - probably not the smartest tho it works.

The problem was, that I thought of a global workflow - but in this global workflow I was not able to access the variables that came from each accordion - so i created a workflow in the modal component and now it works. I sometimes mess things up wenn it comes to workflows on modal lvl …

Thanks anyways!!!

Best