Collapsable cards inside a repeat region do not seem to work as i intend. it seems to collapse all the cards, and expand all the cards on click of any toggle button.
Can anyone advise if they have collapsible cards in a repeat region to toggle on click only the selected card.
You should take care of the id’s
Inside the repeat region you will have to add something dmx-bind:id="name_{{$index}}" This way it will open or colapse the specific id. If all cards have the same id they will open or close all together.
Although it needs to be tested something like the below will work
Change this <div class="card-header" id="accordion1_headingOne">{{productName}}
To this <div class="card-header" dmx-bind:id="accordion1_heading{{$index}}">{{productName}}
This dmx-on:click="accordion1.accordion1_collapseOne.toggle()"
To this dmx-on:click="accordion1.accordion1_collapse{{$index}}.toggle()"
This <div id="accordion1_collapseOne"
To this <div dmx-bind:id="accordion1_collapse{{$index}}"
The idea is that inside the repeat to use dmx-bind:id and not id
With dmx-bind:id you can pass dynamic values to the ids of the collapsible cards so they are unique.
The button element has a data-target of #collapse1 and there is a div inside it with an id of collapse1
Because it is in a repeat region you can not have the same id and data-target more than once so change to dmx-bind:data-target="#collapse{{$index}}" as well as the div id inside it to dmx-bind:id=“collapse{{$index}}”
This way on the first repeat it will be 0 and count up 1, 2, 3 etc.
Great approach, the accordion with an embedded repeat is working well, however I want to add on each repeated row a button that would collapse the corresponding collapse component.
I used
It is a bit difficult to access a component action with a dynamic name, since I don’t know the structure I don’t know if it will work, but it should become something like:
this['col_edittreatment' + $index].hide()
Replace the this with the name/id of the parent component of col_edittreatment when it doesn’t work.
Last time I tried it, I could not get it to work. Probably because I had too dynamic controls nested, and I could not figure out the path to be placed instead of this.
Are you sure this works though?