I encountered a discrepancy between VueJS 1.0 and VueJS 2.0 regarding checkbox behavior. In VueJS 1.0, when binding checkboxes to a list of integers in v-model, the integers do not register as checked attributes.
Below is the HTML code snippet:
<div id="app">
<div class="col-sm-offset-3 col-sm-4 clearfix text-center">
<h4>On Each Day of The Week</h4>
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox1" v-model="schedules[0].by_days" value="1"> M
</label>
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox2" v-model="schedules[0].by_days" value="2"> Tu
</label>
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox3" v-model="schedules[0].by_days" value="3"> W
</label>
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox4" v-model="schedules[0].by_days" value="4"> Th
</label>
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox5" v-model="schedules[0].by_days" value="5"> F
</label>
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox6" v-model="schedules[0].by_days" value="6"> Sa
</label>
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox7" v-model="schedules[0].by_days" value="7"> Su
</label>
<div class="clearfix"></div>
</div>
By Days: {{ schedules[0].by_days.join(', ') }}
</div>
Here is the corresponding JavaScript code snippet:
new Vue({
el: '#app',
data: {
schedules: [
{
'by_days': ["1", 2, 3]
}
]
}
})
When executed, "1" will appear checked, but integers 2 and 3 will not be selected. This works in VueJS 2.0 but not in VueJS 1.0.
For further reference, here is the link to the JSFiddle: https://jsfiddle.net/qf5gqsg6/