@@ -4377,36 +4377,43 @@ <h3 style="color: #f8fafc; margin-bottom: 12px;">No hay tandas</h3>
43774377attachTandasFunctions();
43784378
43794379// === Phase 4: Delegated event listeners for converted inline handlers ===
4380+ // Wrapped in DOMContentLoaded because form/modal HTML is below this script block
43804381(function() {
4381- // Form submits
4382- var editForm = document.getElementById('editGroupForm');
4383- if (editForm) editForm.addEventListener('submit', function(e) { submitGroupEdit(e); });
4384-
4385- var inviteForm = document.getElementById('inviteForm');
4386- if (inviteForm) inviteForm.addEventListener('submit', function(e) { submitSimpleInvitation(e); });
4387-
4388- // User search with debounce
4389- var userSearchInput = document.getElementById('userSearchInput');
4390- if (userSearchInput) {
4391- var _userSearchTimer = null;
4392- userSearchInput.addEventListener('input', function() {
4393- clearTimeout(_userSearchTimer);
4394- var val = this.value;
4395- _userSearchTimer = setTimeout(function() { searchUsersToInvite(val); }, 300);
4396- });
4397- }
4398-
4399- // Proof file upload
4400- var proofFileInput = document.getElementById('proofFileInput');
4401- if (proofFileInput) proofFileInput.addEventListener('change', function(e) { handleProofUpload(e); });
4382+ function _attachPhase4Listeners() {
4383+ // Form submits
4384+ var editForm = document.getElementById('editGroupForm');
4385+ if (editForm) editForm.addEventListener('submit', function(e) { submitGroupEdit(e); });
4386+
4387+ var inviteForm = document.getElementById('inviteForm');
4388+ if (inviteForm) inviteForm.addEventListener('submit', function(e) { submitSimpleInvitation(e); });
4389+
4390+ // User search with debounce
4391+ var userSearchInput = document.getElementById('userSearchInput');
4392+ if (userSearchInput) {
4393+ var _userSearchTimer = null;
4394+ userSearchInput.addEventListener('input', function() {
4395+ clearTimeout(_userSearchTimer);
4396+ var val = this.value;
4397+ _userSearchTimer = setTimeout(function() { searchUsersToInvite(val); }, 300);
4398+ });
4399+ }
44024400
4401+ // Proof file upload
4402+ var proofFileInput = document.getElementById('proofFileInput');
4403+ if (proofFileInput) proofFileInput.addEventListener('change', function(e) { handleProofUpload(e); });
44034404
4404- // History filters
4405- var historyTandaFilter = document.getElementById('historyTandaFilter');
4406- if (historyTandaFilter) historyTandaFilter.addEventListener('change', function() { if (typeof filterHistory === 'function') filterHistory(); });
4405+ // History filters
4406+ var historyTandaFilter = document.getElementById('historyTandaFilter');
4407+ if (historyTandaFilter) historyTandaFilter.addEventListener('change', function() { if (typeof filterHistory === 'function') filterHistory(); });
44074408
4408- var historyPeriodFilter = document.getElementById('historyPeriodFilter');
4409- if (historyPeriodFilter) historyPeriodFilter.addEventListener('change', function() { if (typeof filterHistory === 'function') filterHistory(); });
4409+ var historyPeriodFilter = document.getElementById('historyPeriodFilter');
4410+ if (historyPeriodFilter) historyPeriodFilter.addEventListener('change', function() { if (typeof filterHistory === 'function') filterHistory(); });
4411+ }
4412+ if (document.readyState === 'loading') {
4413+ document.addEventListener('DOMContentLoaded', _attachPhase4Listeners);
4414+ } else {
4415+ _attachPhase4Listeners();
4416+ }
44104417})();
44114418if (document.readyState === "loading") {
44124419 document.addEventListener("DOMContentLoaded", attachTandasFunctions);
0 commit comments