Auto-bind behaviors to elements matching a CSS selector, both existing and dynamically added in the future via MutationObserver.
Returns a cleanup function that disconnects the observer and runs all per-element cleanups returned by the handler.
Optional
const stop = observe('[data-tooltip]', (el) => { const tip = new Tooltip(el); return () => tip.destroy(); }); stop(); // disconnects observer + destroys all tooltips Copy
const stop = observe('[data-tooltip]', (el) => { const tip = new Tooltip(el); return () => tip.destroy(); }); stop(); // disconnects observer + destroys all tooltips
Auto-bind behaviors to elements matching a CSS selector, both existing and dynamically added in the future via MutationObserver.
Returns a cleanup function that disconnects the observer and runs all per-element cleanups returned by the handler.