Collapsible card in repeat region

I don’t know if anyone will find this useful or if it will work on their side, but this worked on my side:

<div class="accordion" id="accordion1" is="dmx-repeat" dmx-bind:repeat="3">
  <div class="card">
	<div class="card-header" dmx-bind:id="card{{$index}}_heading">
	  <h5 class="mb-0">
		<button class="btn btn-link" type="button" data-toggle="collapse" dmx-bind:data-target="{{&quot;#&quot;}}card{{$index}}_collapse" aria-expanded="false" aria-controls="collapse">
		  Collapsible Group Item #{{$index}}
		</button>
	  </h5>
	</div>
	<div dmx-bind:id="card{{$index}}_collapse" class="collapse" is="dmx-bs4-collapse" dmx-bind:aria-labelledby="card{{$index}}_heading" data-parent="#accordion1">
	  <div class="card-body">
		{{$index}}
	  </div>
	</div>
  </div>
</div>

Notes:

  1. This repeat will create 3 accordion cards based on dmx-bind:repeat="3". It is for testing only, you can set it to your own.
  2. It seems that in Wappler, if you want to dynamically bind any parameters, you just need to add dmx-bind: to it.

e.g.
dmx-bind:aria-labelledby="card{{$index}}_heading"
produces the following in my example:

aria-labelledby="card0_heading"
aria-labelledby="card1_heading"
aria-labelledby="card2_heading"

For data-target="#card1_collapse", we need to make sure the # is accepted as a normal string.
e.g…
dmx-bind:data-target="{{&quot;#&quot;}}card{{$index}}_collapse"

Hope this helps.

2 Likes

This doesn’t work. I’ve copied it and the result was that de dmx-bind:id won’t display dynamically the id… I couldn’t make it work. Any ideas? @patrick @Teodor

@salvuccicarlos please confirm this is in your document head section
<script src="/dmxAppConnect/dmxBootstrap4Collapse/dmxBootstrap4Collapse.js" defer=""></script>

If that does not fix it, take a look through this thread please Dynamic Accordion Usage

1 Like