Components

Accordion

Try it yourself on the playground

Playground

JS behaviour

Auto initialisation

In order to automatically initalise the JS behaviour, add data-ecl-auto-init="Accordion2" to your component's markup:

<div class="ecl-accordion2" data-ecl-accordion2 data-ecl-auto-init="Accordion2">
  ...
</div>

Don't forget to call ECL.autoInit() when your page is ready!

Manual initialisation

When the document is ready, query the element. For example, you can use document.querySelector('[data-ecl-accordion2]') if you only have 1 accordion in the page.

Then, instantiate the Accordion2 component and call init():

var elt = document.querySelector('[data-ecl-accordion2]');
var accordion = new ECL.Accordion2(elt);
accordion.init();