How to iterate ID in a Block List for an Accordion - Umbraco 11
So I'm using a Block List to create an Accordion. On principle, it works and renders correctly, but my problem is that my code requires a unique ID on the heading and the collapsed part to work. I'm using Bootstrap 4 and Umbraco 11.
Here is the HTML for each accordion item in the partial view:
I tired it, but it doesn't work. The error says "The name 'blocklistItem' does not exist in the current context". So I'm guessing I need to define it or something.
How to iterate ID in a Block List for an Accordion - Umbraco 11
So I'm using a Block List to create an Accordion. On principle, it works and renders correctly, but my problem is that my code requires a unique ID on the heading and the collapsed part to work. I'm using Bootstrap 4 and Umbraco 11.
Here is the HTML for each accordion item in the partial view:
What I need is code that will automatically iterate the number in #heading and #collapse so that it does not open all cards at the same time.
I was thinking the best way to do it would be with JavaScript. But I am not entirely sure.
Hi Winnie,
Each element in the blocklist has a unique key against it. That is what I would typically use as the unique id.
This saves any double iteration and ensure the header and content stay connected.
Thanks
Nik
I did not know that.
I tired it, but it doesn't work. The error says "The name 'blocklistItem' does not exist in the current context". So I'm guessing I need to define it or something.
Sorry, I'm very new to this.
Here is the entire partial view:
looking at your code, try @content.Key
That was the only one I had not tried. Thanks.
is working on a reply...