can-value
can.view.bindings.can-value
Deprecated 2.3
Use two way binding like {($value)}="KEY"
instead.
Sets up two way bindings in a template.
can-value='KEY'
Binds the element's value or checked property to the value specified by key. Example:
<input type='text' can-value='first.name'/>
Parameters
-
key
{key}
A named value in the current scope.
Use
Add a
can-value="KEY"
attribute to an input or select element and the element's value will be cross-bound to an observable value specified byKEY
.Depending on the element and the element's type,
can-value
takes on different behaviors. If an input element has a type not listed here, the behavior is the same as thetext
type.input type=text
Cross binds the input's string text value with the observable value.
The value of the observable is changed after the input's
change
event, which is afterblur
.input type=checkbox
Cross binds the checked property to a true or false value. An alternative true and false value can be specified by setting
can-true-value
andcan-false-value
attributes.input type='radio'
If the radio element is checked, sets the observable specified by
can-value
to match the value ofvalue
attribute.select
Cross binds the selected option value with an observable value.
textarea
Cross binds the textarea's string text value with the observable value.
The value of the observable is changed after the textarea's
change
event, which is afterblur
.