How can I implement filtering on groups within a Vue app using a nested array with v-model?
I attempted to achieve this using the following template...
<div id="app">
<div class="filter__control filter__control--tags">
<div class="filter__label">Colour</div>
<div class="filter__list">
<label><input type="checkbox" v-model="selectedTags[0]" value="Harvest">Harvest</label>
<label><input type="checkbox" v-model="selectedTags[0]" value="Moss">Moss</label>
<label><input type="checkbox" v-model="selectedTags[0]" value="Navy">Navy</label>
<label><input type="checkbox" v-model="selectedTags[0]" value="White">White</label>
</div>
</div>
<div class="filter__control filter__control--tags">
<div class="filter__label">Size</div>
<div class="filter__list">
<label><input type="checkbox" v-model="selectedTags[1]" value="L">L</label>
<label><input type="checkbox" v-model="selectedTags[1]" value="M">M</label>
<label><input type="checkbox" v-model="selectedTags[1]" value="S">S</label>
<label><input type="checkbox" v-model="selectedTags[1]" value="XL">XL</label>
<label><input type="checkbox" v-model="selectedTags[1]" value="XS">XS</label>
</div>
</div>
</div>
Here is the vue instance configuration...
var app = new Vue({
el: '#app',
data: {
selectedTags: []
},
watch: {
selectedTags: function() {
// Is this the expected format for the selected tags array?
this.selectedTags = [
["Navy"],
["XS", "S"]
]
}
}
});