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

Removing element from iterated array with chekbox does not update the model containing the values of the selected checkboxes #3976

Closed
ragnarlotus opened this issue Oct 18, 2016 · 5 comments
Assignees

Comments

@ragnarlotus
Copy link

Vue.js version

2.0.2

Reproduction Link

http://jsfiddle.net/0eoon3jz/5/

Steps to reproduce

Select the last checkbox or all, then click in the button to remove the last checkbox.

What is Expected?

Expected to remove the value of the checkbox removed from the selecteds variable

What is actually happening?

The value of the removed checkbox remains in the array with the selected checkboxes

Thank you for all your effort!!

@rajibahmed
Copy link

I don't think your expectation from the code is right. You are removing from the items are with the removeItem function. What does it have to do with v-model selected ?

You have added values to your v-model from items.
Then you removed / deleted items ... so you model data is not affected any way.

//Best

@defcc
Copy link
Member

defcc commented Oct 19, 2016

@DEULOS check this issue #3958

Seems to be the same problem. You could use this as a workaroud

@defcc defcc added the 2.0 label Oct 19, 2016
@defcc defcc self-assigned this Oct 19, 2016
@ragnarlotus
Copy link
Author

@defcc it is not the same. When I check or uncheck the checkboxes the model containing the values of the selected checkboxes is updated properly.

@rajibahmed my problem is that if I have a checked checkbox binded to a model, when I remove it feels logical to me to remove its value from the model also.

@rajibahmed
Copy link

@DEULOS

Vue 2.0 is more declarative and less magic. If I have faced this problem I would have to write my own code to solve this, you can add a watcher ( I guess ) to solve this problem.

//Best

@LinusBorg
Copy link
Member

@DEULOS it might seem logical for your usecase, but might not be for someone elses. Maybe someone whant to hide all of the inputs (with v-if), but keep the selected values?

This is a question of your application's logic, and not something Vue should decide for you.

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

No branches or pull requests

4 participants