Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot detect change of array from checkbox v-model? #5398

Closed
bigZ-again opened this issue Apr 8, 2017 · 5 comments · Fixed by #5402
Closed

Cannot detect change of array from checkbox v-model? #5398

bigZ-again opened this issue Apr 8, 2017 · 5 comments · Fixed by #5402

Comments

@bigZ-again
Copy link

bigZ-again commented Apr 8, 2017

Version

2.2.6

Reproduction link

https://fiddle.jshell.net/whoisbigZ/ec11h6gj/2/

Steps to reproduce

I use deep watch to trace an object. See source code, it's very simple.

What is expected?

I hope the setter of v-model should notice deep watch. Why not?

What is actually happening?

But I found the vue cannot detect the array change from checkbox.


I know some caveats about detect the changes of array, but I just use v-model in checkbox.

@posva
Copy link
Member

posva commented Apr 8, 2017

You're falling under this caveat: https://vuejs.org/v2/guide/list.html#Caveats
You can use an object to overcome it (in many ways). Ex: instead of an array for d use an object: {0: true, 1: false} You can also have an array of objects: d: [{model: true}, {model:false}]

@posva posva closed this as completed Apr 8, 2017
@bigZ-again
Copy link
Author

I know everything that @posva said.
But I use v-model to bind a element of array to a input tag with type is checkbox, I don't directly set any element of array, It been done by vue's v-model.
In my demo, I use v-model to bind a element of array to other input tag which type isn't checkbox, the change can be detected.
Why checkbox is NOK! In this case, why v-model don't use Vue.set to set the element of array.
Maybe it isn't a issue, or feature request, PLEASE use vue.set when use v-model to bind a element of array to a checkbox.

@posva
Copy link
Member

posva commented Apr 9, 2017

I'm giving it a deeper look. I'm not sure it's actually intended

@maximelebreton
Copy link

maximelebreton commented Apr 13, 2017

I think I have the same problem:
https://jsfiddle.net/dq90hkb8/1/
Vue 2.2.6

@bigZ-again
Copy link
Author

@maximelebreton Because storedValues.three isn't exist.
You can ref: https://jsfiddle.net/y43nse2o/1/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants