Q-select with q-toggle(q-checkbox too) doesn't check toggle option if model has saved value
Q-select with q-toggle (q-checkbox too) doesn’t check toggle option if model has saved value.
When you choose this option again - it will be duplicated in model.
For me it seems like bug, but it isn’t and I just couldn’t find any good idea how to fix this. Thanks!
Here is example https://codepen.io/taniadiachuk/pen/zYYJeZB
There are two issues:
1.) I think you meant to not set
emit-valueon your q-select, because your model is an array of objects (with label and value) when you initialize it.
That causes the values (only the numbers) to be added to the model when you select an option.
You can (should) either have your model hold values or objects.
2.) To fix the syncronization between the q-select option and the q-toggle, you can replace your q-toggle with this:
<q-toggle :value="scope.selected" @input="change => scope.toggleOption(scope.opt)" />