fixed condition in tab script

This commit is contained in:
Анатолий Богомолов 2024-03-07 20:05:57 +10:00
parent 66fe246f5b
commit 9d8b23ae98
1 changed files with 17 additions and 15 deletions

View File

@ -12,8 +12,7 @@ function setInputsState(section, disabled = false) {
}); });
} }
tabs.forEach((tab) => { function tabSwitchHandler(event) {
tab.addEventListener('hide.bs.tab', event => {
const id_content_hide = event.target.getAttribute('data-bs-target'); const id_content_hide = event.target.getAttribute('data-bs-target');
const id_content_show = event.relatedTarget.getAttribute('data-bs-target'); const id_content_show = event.relatedTarget.getAttribute('data-bs-target');
@ -23,12 +22,15 @@ tabs.forEach((tab) => {
// console.log('==== Show ===='); // console.log('==== Show ====');
const content_show = document.querySelector(id_content_show); const content_show = document.querySelector(id_content_show);
setInputsState(content_show); setInputsState(content_show, false);
}); }
if (!tab.getAttribute('aria-selected')) { tabs.forEach((tab) => {
const id_content_hide = tab.getAttribute('data-bs-target'); tab.addEventListener('hide.bs.tab', tabSwitchHandler);
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); setInputsState(content_hide, true);
} }
}) })