diff --git a/app/blueprints/frontend/static/tabs.js b/app/blueprints/frontend/static/tabs.js index 4bdb78b..10e7d17 100644 --- a/app/blueprints/frontend/static/tabs.js +++ b/app/blueprints/frontend/static/tabs.js @@ -12,23 +12,25 @@ function setInputsState(section, disabled = false) { }); } +function tabSwitchHandler(event) { + const id_content_hide = event.target.getAttribute('data-bs-target'); + const id_content_show = event.relatedTarget.getAttribute('data-bs-target'); + + // console.log('==== Hide ===='); + const content_hide = document.querySelector(id_content_hide); + setInputsState(content_hide, true); + + // console.log('==== Show ===='); + const content_show = document.querySelector(id_content_show); + setInputsState(content_show, false); +} + tabs.forEach((tab) => { - tab.addEventListener('hide.bs.tab', event => { - const id_content_hide = event.target.getAttribute('data-bs-target'); - const id_content_show = event.relatedTarget.getAttribute('data-bs-target'); + tab.addEventListener('hide.bs.tab', tabSwitchHandler); - // console.log('==== Hide ===='); - const content_hide = document.querySelector(id_content_hide); - setInputsState(content_hide, true); - - // console.log('==== Show ===='); - const content_show = document.querySelector(id_content_show); - setInputsState(content_show); - }); - - if (!tab.getAttribute('aria-selected')) { - const id_content_hide = tab.getAttribute('data-bs-target'); - const content_hide = document.querySelector(id_content_hide); + if (tab.getAttribute('aria-selected') == "false") { + let id_content_hide = tab.getAttribute('data-bs-target'); + let content_hide = document.querySelector(id_content_hide); setInputsState(content_hide, true); } }) \ No newline at end of file