Components

Expandables

Try it yourself on the playground

Playground

JS behaviour

Auto initialisation

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

<div class="ecl-expandable" data-ecl-expandable data-ecl-auto-init="Expandable">
  ...
</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-expandable]') if you only have 1 expandable in the page.

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

var elt = document.querySelector('[data-ecl-expandable]');
var expandable = new ECL.Expandable(elt);
expandable.init();