【发布时间】:2013-05-01 23:03:26
【问题描述】:
给定以下 JSON 对象,使用 ko.mapping 进行映射:
{ AllowNotifications: ko.observable(true) }
我想将一个布尔值绑定到一个单选按钮,这样如果为真,则选中一个单选,如果为假,则选中另一个。
<input data-bind="checked: AllowNotifications" type="radio" name="allowNotifications" value="true"><label class="small positive" for="objectNotifications_true">Yes</label>
<input data-bind="checked: AllowNotifications" type="radio" name="allowNotifications" value="false"><label class="small negative" for="objectNotifications_false">No</label>
虽然没有抛出错误,但目前这并没有正确绑定。为什么这不起作用?
【问题讨论】:
标签: knockout.js knockout-mapping-plugin