Accordion page does not demonstrate JavaScript implementation
Created by: alexhorner
The Accordion page https://getbootstrap.com/docs/5.2/components/accordion/ does not have a Usage via JavaScript section like Modal and Collapse does.
Even though Accordion is documented to use Collapse under the hood, it is not clear how to construct a working Accordion using JavaScript. Using the Collapse
JavaScript object's constructor on each of the Accordion elements breaks them, and it is not clear how to properly implement the Collapse.
Ideally, a Usage via JavaScript section would be added to Accordion explaining how to either construct an Accordion, or how to correctly construct a Collapse
object such that all of the Accordion buttons and bodies work correctly, and when opening one Accordion segment, all other Accordion segments close, just like the non-JavaScript-created variant works right now.
This would be very useful for constructing a templated Accordion as a result of an XHR request. Right now, the result of creating a templated Accordion (with unique IDs as appropriate) is a non-functional Accordion.
I have not been able to find a workaround to this issue and I have ended up with a broken, non-functional Accordion with all bodies uncollapsed for now.