diff --git a/app/templates/public/repertoire.php b/app/templates/public/repertoire.php index 41286e0..afd35a2 100644 --- a/app/templates/public/repertoire.php +++ b/app/templates/public/repertoire.php @@ -96,10 +96,12 @@ // Initial bind initAccordions(document); - // Re-bind after HTMX swaps + // Re-bind after HTMX swaps. + // Must query the live DOM — e.detail.target is the *old* detached element after outerHTML swaps. document.body.addEventListener('htmx:afterSwap', function (e) { if (e.detail.target && e.detail.target.matches && e.detail.target.matches(INDEX_SEL)) { - initAccordions(e.detail.target); + var liveIndex = document.querySelector(INDEX_SEL); + if (liveIndex) initAccordions(liveIndex); } });