I'm attempting to add an active class to an element for tabs navigation using vue.js. The problem is, besides being new to Vue, the navigation items are dynamically created in a for loop as follows:
<c:forEach items="${tabnav.tabs}" var="tab" varStatus="loop">
<c:if test="${loop.count le tabnav.totalTabs}">
<li v-bind:class="{active : isActive}" v-on:click="tabSelected = ${loop.count}; isActive = !isActive">${tab.heading}</li>
</c:if>
</c:forEach>
the JS looks like this:
Vue.component('tabnav', {
data: function() {
return {
tabSelected: 1,
isActive: false
};
}
});
The problem is that this is toggling the class on ALL the items in the navigation rather than the one that was clicked.
Do I need to create a method for handling this?