我正在使用带有 Kendo 框架的 ASP.NET MVC 应用程序。出于某种原因,我总是让复选框“#IsInterestDeemed”处于勾选状态。虽然,视图模型属性“IsInterest”在控制器操作方法下为假。请建议我在哪里犯了错误。
<div id="RunModelDiv" style="min-width:300px">
<div>
<input type="checkbox" id="IsInterestDeemed" value="IsInterestDeemed" data-bind="checked: IsInterestDeemed, disabled: IsReadOnly" />
<label for="IsInterestDeemed"> Interest</label>
</div>
<div>
<script>
var myViewModel;
$(document).ready(function(){
myViewModel = kendo.observable({
IsReadOnly: @Html.Raw(Json.Encode(Model.IsReadOnly)),
IsInterestDeemed : '@Html.Raw(Json.Encode(Model.IsInterest))'});
kendo.bind($("#RunModelDiv"), myViewModel);
});
</script>
ViewModel 属性:-
public bool IsInterest { get; set; }
public bool IsReadOnly { get; set; }