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

Checkbox does not allow dynamic values #1277

Closed
philBrown opened this issue Dec 7, 2017 · 7 comments
Closed

Checkbox does not allow dynamic values #1277

philBrown opened this issue Dec 7, 2017 · 7 comments

Comments

@philBrown
Copy link

Say I have an array of objects and want to use checkboxes to create a filtered set of attributes, for example

{
things: [{id: 1, name: 'One'}, {id: 2, name: 'Two'}, {id: 3, name: 'Three'} ... ],
selectedThings: []
}

Because you've used v-model in the checkbox component, we cannot bind the value attribute like this.

<div v-for="thing in things" :key="thing.id">
  <md-checkbox v-model="selectedThings" :value="thing.id"/>
  <span>{{thing.name}}</span>
</div>

Vue triggers the error...

  • :value conflicts with v-model on the same element because the latter already expands to a value binding internally

All you would have to do is use a different prop name than value.

@philBrown
Copy link
Author

Ah, after looking through the source code, I see I can use :model instead of v-model to get around this limitation.

Might be good to add that to the documentation :)

@Samuell1
Copy link
Member

Samuell1 commented Dec 7, 2017

This is weird because i tested it and i doesnt get any error.

@philBrown
Copy link
Author

I'm using Vue 2.5.5 if that helps. The error was reported by vue-template-compiler

@Samuell1
Copy link
Member

Samuell1 commented Dec 7, 2017

@philBrown update vue and vue-template-compiler to 2.5.9 and should work

@philBrown
Copy link
Author

Yep, that sorted it :)

@Samuell1 Samuell1 closed this as completed Dec 7, 2017
@philBrown
Copy link
Author

For reference ~ vuejs/vue#7084

@Samuell1
Copy link
Member

Samuell1 commented Dec 7, 2017

Yeah we had this issue few weeks ago #1167

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

2 participants