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?

http://plnkr.co/edit/g5cw9i?p=preview

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

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -