-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
v-bind="$attrs" and problems with "value" attribute for multi-checkboxes #7914
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
Comments
Check the modified codepen. I changed the component logic to match default native multi checkbox behavior. |
@emanuelmutschlechner I don't think your codepen is relevant here (though I appreciate you working toward a solution!). Adding an explicit
|
@pearofducks If you want |
@emanuelmutschlechner - please read my previous response. With |
I get your point, but I'm not sure if this is a bug or not. We need some feedback from the core team. My solution is partly based on this example code, where Vue.component('base-input', {
inheritAttrs: false,
props: ['label', 'value'],
computed: {
inputListeners: function () {
var vm = this
// `Object.assign` merges objects together to form a new object
return Object.assign({},
// We add all the listeners from the parent
this.$listeners,
// Then we can add custom listeners or override the
// behavior of some listeners.
{
// This ensures that the component works with v-model
input: function (event) {
vm.$emit('input', event.target.value)
}
}
)
}
},
template: `
<label>
{{ label }}
<input
v-bind="$attrs"
v-bind:value="value"
v-on="inputListeners"
>
</label>
`
}) |
Maybe this issue is somewhat related to #6216? |
I think both of you are right. And, @emanuelmutschlechner, you are correct, right now this is the way of doing it: @chrisvfritz explains the state of the art and future approaches here: |
Just wanted to that i've also faced this in my project.
So yeah, we have to explicitly set the :value to make things work, as @emanuelmutschlechner said earlier. |
Version
2.5.16
Reproduction link
https://codepen.io/anon/pen/aYqoYL?editors=1010
Steps to reproduce
What is expected?
(or, the
value
never hits the DOM element, the fact that it is present on the DOM element but isn't used in the model is a conflict IMO)What is actually happening?
The text was updated successfully, but these errors were encountered: