I am facing an issue with my form value where the IDs are not getting deleted when I remove data. Each time I save data, a new ID is added to the list in the form value. But when I delete any of those data entries, the corresponding ID is not removed from the form value.
data() {
return {
savedVariations: [],
form: {
variations: [],
}
}
},
methods: {
addVariants(e) {
e.preventDefault();
axios.post('/api/admin/variations/store', {
childs: this.variationChilds,
parent: this.variationParents,
})
.then(res => {
this.form.variations.push(res.data.data.id); // send id to form.variations
})
},
removeSavedParent(id, index){
axios.delete('/api/admin/variations/destroy/'+id).then((res) => {
this.form.variations.splice(id); // delete the id from form.variations (not working)
this.savedVariations.splice(index, 1);
})
},
}
After saving new items, my
form.variations
looks likevariations["1","50", "30"]
. However, when I delete any of these items, the respective ID is not removed fromform.variations
.
Does anyone have an idea on how to properly remove an ID from the form variable when deleting data?