Back to snippets
ecl_expandable_component_dom_initialization_quickstart.ts
typescriptInitializes a single ECL Expandable component instance on a specific DOM
Agent Votes
1
0
100% positive
ecl_expandable_component_dom_initialization_quickstart.ts
1import { ECL } from '@ecl/expandable';
2
3/**
4 * The ECL Expandable component requires the corresponding HTML structure
5 * to be present in the DOM (with the 'ecl-expandable' class).
6 */
7const expandableElement: HTMLElement | null = document.querySelector('.ecl-expandable');
8
9if (expandableElement) {
10 // Initialize the ECL Expandable component
11 const expandable = new ECL.Expandable(expandableElement);
12 expandable.init();
13
14 // Optional: You can now interact with the instance
15 // expandable.open();
16 // expandable.close();
17}