25 lines
570 B
HTML
25 lines
570 B
HTML
const isExpanding = btn.textContent.trim() === 'Expand All';
|
|
|
|
details.forEach(detail => {
|
|
if (isExpanding) {
|
|
detail.setAttribute('open', '');
|
|
} else {
|
|
detail.removeAttribute('open');
|
|
}
|
|
});
|
|
|
|
btn.textContent = isExpanding ? 'Collapse All' : 'Expand All';
|
|
}
|
|
|
|
// Reset button state when HTMX updates the list
|
|
document.body.addEventListener('htmx:afterSwap', function (evt) {
|
|
if (evt.detail.target.id === 'function-list') {
|
|
const btn = document.getElementById('toggle-btn');
|
|
if (btn) {
|
|
btn.textContent = 'Expand All';
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
|
|
{% endblock %} |