I cannot for the life of me figure this out.
Fiddle at: https://jsfiddle.net/s8xvkt10/
I want
- User clicks checkbox
- Then based on separate conditions
- Checkbox
calculatedCheckedValue
returns a data property /v-model of true/false - And the checked state reflects the calculatedCheckedValue
I can get:
- The
calculatedCheckedValue
calculates and interpolates properly
But I fail at:
- Having the :checked attribute render the
calculatedCheckedValue
properly in the DOM - e.g. If a
false
checkbox is clicked and thecalculatedCheckedValue
still returnsfalse
, the checkbox toggles onscreen between checked and unchecked
I’ve tried:
- Using a
v-model
with a customset
that does the calculation and sets the local state which the customget
returns - Imitating a v-model using
@change.prevent.stop="updateCalculatedValue"
and:checked="calculatedValue"
- Assuming the @change happens after the @click (which i think is wrong) and using
@click.prevent.stop="updateCalculatedValue"
and:checked="calculatedValue"
The model is working and rendering the calculated value as string in a DOM span, but the checked value doesn't seem to respect the model value
Can someone please help me out?