I'm in process migrating an application from Vue 1.x to 2.0.3. In this application I'm having several selects where each v-model binds to an individual index of an array . This is without problems in Vue 1.x but in version 2 it does not update. I believe this is a potential bug.
I have reproduced the problem here:
https://jsfiddle.net/peterkorgaard/a7vvz753/18/
2.0.3
https://jsfiddle.net/peterkorgaard/a7vvz753/18/
I am looking into this. Seems selections do not get Observered correctly
@peterkorgaard I update the fiddler here https://jsfiddle.net/defcc/a7vvz753/20/, You could use like this as a workaround.
For more info, take a look at this http://vuejs.org/guide/reactivity.html#Change-Detection-Caveats
I got the same question.
@defcc Your solution can solve that we already know how many items of the model. If change the model from array to object, how can we do?
You should use object type, as model binding uses model[index]= in internal implementation. If you use array type, the value could not be observed. http://vuejs.org/guide/list.html#Caveats
You could init the selections when created, and update the selections after the selectBoxes data updated.
I update the fiddler here https://jsfiddle.net/defcc/a7vvz753/21/
@defcc Bravo, this solution worked for me fine. Thank you so much!
Thank you, @defcc, for clarifying this. I will use this workaround until the problem gets solved. And thanks for the great work everybody does on Vue. I'm really amazed.
Most helpful comment
You should use object type, as model binding uses model[index]= in internal implementation. If you use array type, the value could not be observed. http://vuejs.org/guide/list.html#Caveats
You could init the selections when created, and update the selections after the selectBoxes data updated.
I update the fiddler here https://jsfiddle.net/defcc/a7vvz753/21/