There are 2 toggle buttons. If the value is true
, it will be added to the array
, otherwise the element will be removed.
data:
originality: []
toggles:
<toggle id='1' ref='toggleOriginal'> Click </toggle>
<toggle id='2' ref='toggleAnalog'> Click </toggle>
methods:
if(this.$refs.toggleOriginal.isActive) {
this.originality.push(this.$refs.toggleOriginal.id);
} else {
this.originality = this.originality.filter((item) => {
return item == this.$refs.toggleOriginal.id;
});
}
if(this.$refs.toggleAnalog.isActive) {
this.originality.push(this.$refs.toggleAnalog.id);
} else {
this.originality = this.originality.filter((item) => {
return item == this.$refs.toggleAnalog.id;
});
}
And the same for the second button. The `isActive` parameter checks for `true/false`. The issue arises when both toggles are set to `true` and then one needs to be changed to `false`, resulting in the wrong element being removed. Is there a different functionality that should be used in this situation?