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
calculatedCheckedValuereturns a data property /v-model of true/false - And the checked state reflects the calculatedCheckedValue
I can get:
- The
calculatedCheckedValuecalculates and interpolates properly
But I fail at:
- Having the :checked attribute render the
calculatedCheckedValueproperly in the DOM - e.g. If a
falsecheckbox is clicked and thecalculatedCheckedValuestill returnsfalse, the checkbox toggles onscreen between checked and unchecked
I’ve tried:
- Using a
v-modelwith a customsetthat does the calculation and sets the local state which the customgetreturns - 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?