Refactor to use v-model
This commit is contained in:
parent
2743bddf0c
commit
53a6c73510
@ -32,15 +32,14 @@ export default {
|
|||||||
showValid: !showError && !!this.initialValue,
|
showValid: !showError && !!this.initialValue,
|
||||||
validationError: this.initialErrors.join(' '),
|
validationError: this.initialErrors.join(' '),
|
||||||
otherChecked: this.initialValue.includes("other") ? true : this.otherChecked,
|
otherChecked: this.initialValue.includes("other") ? true : this.otherChecked,
|
||||||
otherText: this.initialOtherValue
|
otherText: this.initialOtherValue,
|
||||||
|
selections: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
for (let child of this.$el.firstChild.lastElementChild.children) {
|
for (let choice of this.initialValue) {
|
||||||
if (this.initialValue.includes(child.firstChild.value)) {
|
this.selections.push(choice)
|
||||||
child.firstChild.checked = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
{% macro MultiCheckboxInput(field, other_input_field, tooltip, inline=False) -%}
|
{% macro MultiCheckboxInput(field, other_input_field, tooltip, inline=False) -%}
|
||||||
<multicheckboxinput
|
<multicheckboxinput
|
||||||
|
v-cloak
|
||||||
name='{{ field.name }}'
|
name='{{ field.name }}'
|
||||||
inline-template
|
inline-template
|
||||||
{% if field.errors %}v-bind:initial-errors='{{ field.errors | list }}'{% endif %}
|
{% if field.errors %}v-bind:initial-errors='{{ field.errors | list }}'{% endif %}
|
||||||
@ -31,10 +32,10 @@
|
|||||||
{% for choice in field.choices %}
|
{% for choice in field.choices %}
|
||||||
<li>
|
<li>
|
||||||
{% if choice[0] != 'other' %}
|
{% if choice[0] != 'other' %}
|
||||||
<input type='checkbox' name='{{ field.name }}' id='{{ field.name }}-{{ field.choices.index(choice) }}' value='{{ choice[0] }}'/>
|
<input type='checkbox' name='{{ field.name }}' id='{{ field.name }}-{{ field.choices.index(choice) }}' value='{{ choice[0] }}' v-model="selections"/>
|
||||||
<label for='{{ field.name }}-{{ field.choices.index(choice) }}'>{{ choice[1] }}</label>
|
<label for='{{ field.name }}-{{ field.choices.index(choice) }}'>{{ choice[1] }}</label>
|
||||||
{% else %}
|
{% else %}
|
||||||
<input @click="otherToggle" type='checkbox' name='{{ field.name }}' id='{{ field.name }}-{{ field.choices.index(choice) }}' value='other'/>
|
<input @click="otherToggle" type='checkbox' name='{{ field.name }}' id='{{ field.name }}-{{ field.choices.index(choice) }}' value='other' v-model="selections"/>
|
||||||
<label for='{{ field.name }}-{{ field.choices.index(choice) }}'>{{ choice[1] }}</label>
|
<label for='{{ field.name }}-{{ field.choices.index(choice) }}'>{{ choice[1] }}</label>
|
||||||
|
|
||||||
<div v-show="otherChecked">
|
<div v-show="otherChecked">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user