I have dynamic list of options which comes from api:
<tr v-for="(option, index) in options">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="toggle" v-model="options.value" @click="toggleOption(option.id, index)">
<label class="custom-control-label" for="toggle"></label>
</div>
Method:
toggleOption(id, index) {
let app = this;
let option = this.options[index];
app.loading = true;
option.value = !option.value;
axios.patch('/apiendoint' + id, option)
.then(function (resp) {
app.loading = false;
})
.catch(function (resp) {
});
}
When checkbox is clicked all checkboxes changes, if only one item comes from api everything is working. How to make to work it with multiple checkboxes?
Aucun commentaire:
Enregistrer un commentaire