0👍
It seems like you’re just toggling the checkboxes on and off based on the result of checkDistances
, but not storing them anywhere. The organization of your example isn’t 100% clear to me, but you probably want something along these lines:
// In your template
<input
:id="car.slug+index"
:name="car.slug"
type="checkbox"
:checked="distance in car.distances"
@click="addDistanceToCar(distance, car)" />
// In your methods:
addDistanceToCar(distance, car) {
car.distances.push(distance)
}
Source:stackexchange.com