auto close of items dropdown
This commit is contained in:
@@ -109,5 +109,24 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
/* ─── EIBS: allow only one open panel ─── */
|
||||||
|
const allCollapses = document.querySelectorAll('.collapse');
|
||||||
|
|
||||||
|
allCollapses.forEach(function (panel) {
|
||||||
|
/* When any panel STARTS to open… */
|
||||||
|
panel.addEventListener('show.bs.collapse', function () {
|
||||||
|
|
||||||
|
/* …loop through every other panel… */
|
||||||
|
allCollapses.forEach(function (openPanel) {
|
||||||
|
if (openPanel !== panel && openPanel.classList.contains('show')) {
|
||||||
|
/* …and close it. */
|
||||||
|
/* If Bootstrap already has an instance → use it, otherwise create one on the fly */
|
||||||
|
(bootstrap.Collapse.getInstance(openPanel) ||
|
||||||
|
new bootstrap.Collapse(openPanel))
|
||||||
|
.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user