2016-11-21 72 views
0

我使用ASP.NET MVC應用程序與劍道框架。出於某種原因,我總是得到勾選「#IsInterestDeemed」的勾選狀態。雖然,在ViewModel財產「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">&nbsp;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> 

視圖模型屬性: -

public bool IsInterest { get; set; } 
public bool IsReadOnly { get; set; } 

回答

1

爲什麼是IsReadOnlyIsInterestDeemed在JavaScript的處理方式不同的值(一個是字符串,另一個是原始文本)?也許這是在頁面加載時導致語法錯誤的原因,因此頁面不會按預期運行。

更具體地說,這兩條線是不一致的:

IsReadOnly: @Html.Raw(Json.Encode(Model.IsReadOnly)) 
IsInterestDeemed : '@Html.Raw(Json.Encode(Model.IsInterest))' 

檢查HTML輸出並驗證您的解決方案。

+0

IsReadOnly也是一個布爾屬性 – Karan

+0

所以,如果他們都是布爾類型,或許他們應該如何處理相同(提示:行情) –

+0

我甚至移除了數據綁定屬性的選項被禁用,仍然沒有運氣.. – Karan