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,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) => { tabs.forEach((tab) => {
tab.addEventListener('hide.bs.tab', event => { tab.addEventListener('hide.bs.tab', tabSwitchHandler);
const id_content_hide = event.target.getAttribute('data-bs-target');
const id_content_show = event.relatedTarget.getAttribute('data-bs-target');
// console.log('==== Hide ===='); if (tab.getAttribute('aria-selected') == "false") {
const content_hide = document.querySelector(id_content_hide); let id_content_hide = tab.getAttribute('data-bs-target');
setInputsState(content_hide, true); let content_hide = document.querySelector(id_content_hide);
// 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);
setInputsState(content_hide, true); setInputsState(content_hide, true);
} }
}) })