【发布时间】:2013-04-26 17:58:01
【问题描述】:
我正在使用带有 MVC 4 的 Knockout。我的 cshtml 是:
...
<span>@Html.RadioButtonFor(m => m.isActive, true, new { @class = "statusRadioButton", data_bind = "checked: isActive" })</span>
<span>@Html.RadioButtonFor(m => m.isActive, false, new { @class = "statusRadioButton", data_bind = "checked: isActive" })</span>
...
我的哥:
...
self.isActive = ko.observable(product.isActive);
...
它正确更新数据库,但它在页面加载时未显示任何已选中的单选按钮。我也尝试使用 checked = "checked" html 属性,但它也不起作用。有什么建议吗?
【问题讨论】:
-
product.isActive是否可观察?
标签: asp.net-mvc-4 razor knockout.js radio-button html-helper