diff --git a/resources/js/dynamicSearch.js b/resources/js/dynamicSearch.js index ed11269..453ab44 100644 --- a/resources/js/dynamicSearch.js +++ b/resources/js/dynamicSearch.js @@ -145,13 +145,22 @@ function handleHierarchicalTaxonomyCheckboxRelation(e) { if (e.target.checked && e.target.classList.contains('parent-checkbox')) { const parentRootTag = e.target.closest('.checkbox-choice'); const children = parentRootTag.querySelectorAll('.child-checkbox'); - - children.forEach((child) => { + //alert('check parent là'); + /*children.forEach((child) => { child.checked = true; - }); + });*/ } + + if (e.target.checked && e.target.classList.contains('child-checkbox')) { + //alert('check child là'); + const checkboxRootTag = e.target.closest('.checkbox-choice'); + const parentCheckbox = checkboxRootTag.parentElement.parentElement.querySelector('.parent-checkbox'); + + parentCheckbox.checked = false; + } + if (!e.target.checked && e.target.classList.contains('parent-checkbox')) { - // alert('uncheck parent'); + //alert('uncheck parent'); const parent = e.target.closest('.checkbox-choice'); const children = parent.querySelectorAll('.child-checkbox');