Binding true / false to radio buttons in Knockout JS

后端 未结 8 2341
悲哀的现实
悲哀的现实 2020-11-30 22:09

In my view model I have a IsMale value that has the value true or false.

In my UI I wish to bind it to the following radio buttons:

8条回答
  •  感情败类
    2020-11-30 22:30

    I know this is an old thread, but I was having the same problem and found out a much better solution that was probably added to knockout after this question was officially answered, so I'll just leave it for people with the same problem.

    Currently there is no need for extenders, custom binding handlers or computeds. Just provide a "checkedValue" option, it will use that instead of the html 'value' attribute, and with that you can pass any javascript value.

    
    
    

    Or:

    
    
    
    

提交回复
热议问题