diff --git a/konova/templates/konova/widgets/tree/radio/radio-tree-select.html b/konova/templates/konova/widgets/tree/radio/radio-tree-select.html index 87df9f2f..0c919c39 100644 --- a/konova/templates/konova/widgets/tree/radio/radio-tree-select.html +++ b/konova/templates/konova/widgets/tree/radio/radio-tree-select.html @@ -12,24 +12,16 @@ element = $(element); var cssClass = "badge rlp-r" - var directParent = element.closest(".tree-element-children") - var root = element.parents(".tree-element-children") + // Find all already tagged input elements and reset them to be untagged + var allTaggedInputs = $("#tree-root").find(".badge.rlp-r") + allTaggedInputs.removeClass(cssClass) - var otherCheckedInputsOfParent = directParent.find('.tree-input:checked'); - var otherCheckedInputsOfRoot = root.find('.tree-input:checked'); - - if(otherCheckedInputsOfParent.length == 0){ - var parentLabel = directParent.siblings(".tree-label"); - parentLabel.removeClass(cssClass) - if(otherCheckedInputsOfRoot.length == 0){ - var rootLabel = root.siblings(".tree-label") - rootLabel.removeClass(cssClass) - } - }else{ - var rootAndParentLabel = root.siblings(".tree-label"); - rootAndParentLabel.addClass(cssClass); - } + // Find all parents of selected element + var parentElements = element.parents(".tree-element-children") + // Tag parents of element + var parentLabels = parentElements.siblings(".tree-label"); + parentLabels.addClass(cssClass); } function changeHandler(event){