aurelia - binding values to radio buttons -
i'm trying bind radio buttons 'checked' status boolean values in json object, it's not being set.
template: (jobreadinessitems array of "items")
<tbody> <tr repeat.for="item of jobreadinessitems"> <td><input id="have" name="readiness" type="radio" checked.bind="item.have" /></td> <td><input id="need" name="readiness" type="radio" checked.bind="item.need" /></td> </tr>
item (json):
{ have: false, need: true }
cs
public class jobreadinessitemdto { public bool have { get; set; } public bool need { get; set; } }
however, if bind way shows values (but of course can't set it):
checked.bind="item.have ? 'on' : 'off'"
why display "on/off" not true/false?
have @ cheat-sheet in aurelia docs:
http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/cheat-sheet
search "radio" , you'll find few examples might helpful reference. 1 thing jumps out @ me right away though:
<tr repeat.for="item of jobreadinessitems">
this should iterate on array, jobreadinessitems
object:
{ have: false, need: true }
you should either change array:
[ {value: 'have', checked: false}, {value: 'need', checked: true} ]
...and bind accordingly in template, or change template bind object values directly. hope helps.
edit: new cheat sheet url http://aurelia.io/docs/fundamentals/cheat-sheet/
Comments
Post a Comment