diff --git a/app/views/admin/conferences/import_history.html.erb b/app/views/admin/conferences/import_history.html.erb index e5e4583df8d58794b124a439a00c311ad2aa93cf..1bb6df732fe3198a84870f9ce33e2cdf371f3a8c 100644 --- a/app/views/admin/conferences/import_history.html.erb +++ b/app/views/admin/conferences/import_history.html.erb @@ -116,7 +116,7 @@ </template> <script> - document.addEventListener('DOMContentLoaded', function() { + document.addEventListener('turbo:load', function() { document.querySelectorAll('[data-action="view-error"]').forEach(function(button) { button.addEventListener('click', function() { const errorContent = this.getAttribute('data-error'); diff --git a/app/views/admin/conferences/import_progress.html.erb b/app/views/admin/conferences/import_progress.html.erb index 7b9a9dde3c2e60fe62afc37edcb01290386cb0a5..6bb25b5a2a204a40db88b07c1af4520f26144c1d 100644 --- a/app/views/admin/conferences/import_progress.html.erb +++ b/app/views/admin/conferences/import_progress.html.erb @@ -62,6 +62,6 @@ }); } - document.addEventListener('DOMContentLoaded', checkImportStatus); + document.addEventListener('turbo:load', checkImportStatus); </script> </div> diff --git a/app/views/assignments/by_user.html.erb b/app/views/assignments/by_user.html.erb index e030d9c6ebd5942cab70ed8db091f444617e36f5..cec5c1084e18b8d4f00bd4f850d63ba4926ba9ad 100644 --- a/app/views/assignments/by_user.html.erb +++ b/app/views/assignments/by_user.html.erb @@ -94,7 +94,7 @@ </div> <script> - document.addEventListener('DOMContentLoaded', function() { + document.addEventListener('turbo:load', function() { const tabButtons = document.querySelectorAll('[data-tabs-target]'); const tabContents = document.querySelectorAll('[role="tabpanel"]'); diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 39a11046e8ad34cb50b612d5e86d5a60bfed7fcc..62ca4392c579163b801a8a565915ab27b33ace59 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -110,7 +110,7 @@ <script> // Toggle password fields - document.addEventListener('DOMContentLoaded', function() { + document.addEventListener('turbo:load', function() { const togglePasswordBtn = document.getElementById('togglePasswordFields'); const passwordFields = document.getElementById('passwordFields'); diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 44c4b95a9de7b44133bbc4e9681cee52907f4bdb..5597e8de24cc19808b27a86234b97bd7e50439b0 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -245,21 +245,11 @@ // Set user signed in state for JS window.userSignedIn = <%= user_signed_in? %>; - // Initialize on DOMContentLoaded - document.addEventListener('DOMContentLoaded', () => { - initializeThemeToggle(); - initializeNavMenus(); - }); - // Re-initialize on Turbo navigation document.addEventListener('turbo:load', () => { initializeThemeToggle(); initializeNavMenus(); }); - document.addEventListener('turbo:render', () => { - initializeThemeToggle(); - initializeNavMenus(); - }); </script> <main> diff --git a/app/views/shared/_admin_nav.html.erb b/app/views/shared/_admin_nav.html.erb index cc78a3eff86124dc0c7fc3848650efa89e2b001e..626682e9c6db4ce5cd851554b2424ea91be73c29 100644 --- a/app/views/shared/_admin_nav.html.erb +++ b/app/views/shared/_admin_nav.html.erb @@ -84,11 +84,7 @@ } } - // Initialize on DOMContentLoaded - document.addEventListener('DOMContentLoaded', initializeAdminNavMenu); - - // Re-initialize on Turbo navigation + // Initialize on Turbo page load document.addEventListener('turbo:load', initializeAdminNavMenu); - document.addEventListener('turbo:render', initializeAdminNavMenu); </script> </header>