fix: close all modals on page load and before form submit
This commit is contained in:
parent
4917bba468
commit
9ed12fa1d8
1 changed files with 15 additions and 0 deletions
|
|
@ -1,6 +1,11 @@
|
||||||
function initApp() {
|
function initApp() {
|
||||||
console.log('sub-aligator app.js initialized');
|
console.log('sub-aligator app.js initialized');
|
||||||
|
|
||||||
|
// Ensure every modal starts closed, even if the browser restored a cached state.
|
||||||
|
document.querySelectorAll('.modal-overlay').forEach(function (modal) {
|
||||||
|
modal.style.display = 'none';
|
||||||
|
});
|
||||||
|
|
||||||
// Open allocation modal
|
// Open allocation modal
|
||||||
document.querySelectorAll('.allocate-btn').forEach(function (btn) {
|
document.querySelectorAll('.allocate-btn').forEach(function (btn) {
|
||||||
btn.addEventListener('click', function () {
|
btn.addEventListener('click', function () {
|
||||||
|
|
@ -46,6 +51,16 @@ function initApp() {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hide the modal right before its form is submitted.
|
||||||
|
document.querySelectorAll('.modal form').forEach(function (form) {
|
||||||
|
form.addEventListener('submit', function () {
|
||||||
|
const overlay = form.closest('.modal-overlay');
|
||||||
|
if (overlay) {
|
||||||
|
overlay.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openAllocateModal(btn) {
|
async function openAllocateModal(btn) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue