document.addEventListener('livewire:navigated', () => {
const statePath = 'item';
function procesarToggle(toggle) {
const idAttr = toggle.getAttribute('id');
const match = idAttr.match(/record-\d+/);
if (!match) return;
const itemKey = match[0];
const checked = toggle.getAttribute('aria-checked') === 'true';
if (checked) {
window.Livewire.dispatch('repeater::collapseItem', { statePath, itemKey });
} else {
window.Livewire.dispatch('repeater::expandItem', { statePath, itemKey });
}
}
function configurarEventos() {
const toggles = document.querySelectorAll(`button[id^="data.${statePath}"][id$=".done"]`);
toggles.forEach((toggle) => {
procesarToggle(toggle);
});
}
configurarEventos();
});
document.addEventListener('livewire:navigated', () => {
const statePath = 'item';
function procesarToggle(toggle) {
const idAttr = toggle.getAttribute('id');
const match = idAttr.match(/record-\d+/);
if (!match) return;
const itemKey = match[0];
const checked = toggle.getAttribute('aria-checked') === 'true';
if (checked) {
window.Livewire.dispatch('repeater::collapseItem', { statePath, itemKey });
} else {
window.Livewire.dispatch('repeater::expandItem', { statePath, itemKey });
}
}
function configurarEventos() {
const toggles = document.querySelectorAll(`button[id^="data.${statePath}"][id$=".done"]`);
toggles.forEach((toggle) => {
procesarToggle(toggle);
});
}
configurarEventos();
});