right now I'm working on Episerver webapp and Im new to vue.js so I need your help.. I need to detect accordion inside accordion so I can give it left margin thus indent, so its clear its accordion inside accordion and not just two accordions after one another.
current cshtml looks like this :
<generic-component inline-template class="vue-block-app" server-rendered="true" >
<div>
<div v-bind:class="{isNested: isNested('@collapseId','collapsible-list-item-block')}" class="collapsible-list-item-block grid @Model.GetHiddenPrintClassName">
<div class="collapsible-list-item-block__heading" id="headingOne" @@click="collapsibleClicked('@collapseId')">
<div class="@collapseButtonClass" v-b-toggle="'@collapseId'" variant="primary">
<div class="text-line-content">@Html.PropertyFor(m => m.Title)</div>
<div class="icon-wrap float-right">
<span class="collapseIcon">@{Html.RenderCollapseIcon();}</span>
<span class="expandIcon">@{Html.RenderExpandIcon();}</span>
</div>
</div>
</div>
<b-collapse id="@collapseId" @collapsedByDefault class="collapsible-list-item-block__content" style="display: none;">
@Html.PropertyFor(m => m.Content)
</b-collapse>
</div>
</div>
my vue file looks like this:
<script>
import componentMounted from '../mixins/component-mounted';
export default {
mixins: [componentMounted],
data() {
return {
isNestedAccordion: false,
};
},
computed: {
},
methods: {
collapsibleClicked(id) {
$(window).trigger("collapseClicked", [id]);
},
isNested(id, className) {
var element = document.getElementById(id);
do {
if (element.classList && element.classList.contains(className)) {
console.log("true")
return true;
}
element = element.parentElement.parentElement;
} while (element);
console.log("false")
return false;
}
}
}
and css class .isNested{margin-left:20px;}
what Im I doin wrong that Im not getting class to my div.... Btw, when I had my isNested() inside collapsibleClicked() it worked just fine on click... what am I missing?