-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
v-model radio and checkbox expressions #1129
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
Conversation
this._getValue = getValue | ||
|
||
function matchValue (value) { | ||
var trueValue = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since el.checked
can be only true
or false
, we just need to check if value
equals trueValue
here - in all other cases we just return false. This could make matchValue
much simpler.
Yes makes sense to use |
Cool! Mind rebasing against latest |
…the result of evaluated expression
Hitting the limits of my git knowledge here, I've re-based |
Here's what you should probably do:
|
That seemed to work |
v-model radio and checkbox expressions
Thanks! |
Radio input
Added the ability to specify an expression, via attribute
exp
, which will be evaluated on the current scope and set as the v-model value when the radio is selected, similar to Angularng-value
. e.g.If the first radio is selected,
model.radio === true
instead of"1"
. When the model updates andexp
is present, we match the evaluated expression rather than thevalue
string when choosing which radio to set aschecked
.Checkbox input
Added the ability to specify a
true-value
andfalse-value
which will override the defaulttrue
/false
values. Similar to Angularng-true-value
andng-false-value
. e.g:If present
true-value
andfalse-value
will be evaluated on the current scope, and set as the v-model value when the checkbox changes. Similar to the radio, if the model changes a comparison is made againsttrue-value
andfalse-value
values to determine the checkbox state.