2014-02-10 40 views
0

我試圖找出如何禁用Html.Checkbox與給定的語法:禁用Html.CheckBox

@Html.CheckBox("checkbox_" + Model.QuestionId.ToString(), false, 
       new Dictionary<string, object> {{ "data-bind", "checked: $root.getResponse(@Model.QuestionId).Value" }}) 

淘汰賽代碼:

self.getResponse = function (questionId) { 
     var rv = ko.utils.arrayFirst(self.responses(), function (item) { return item.QuestionId ==  questionId; }); 
     if (rv == null) { 
      rv = new Response(0, questionId, self.evaluationId, 0, 0, '', ''); self.responses.push(rv); 
     } 
     return rv; 
} 

請幫

+0

$ root.getResponse從哪裏來? – jacqijvv

+0

敲除:self.getResponse =函數(questionId) { 變種RV = ko.utils.arrayFirst(self.responses(),函數(項目) { 返回item.QuestionId == questionId; }); if(rv == null) rv = new Response(0,questionId,self.evaluationId,0,0,'',''); self.responses.push(rv); } return rv; } – user3272686

回答

1

數據-bind ='enable:isEnabled'

你想測試這個複選框是否應該啓用。我不知道你的標準被啓用,但這裏是啓用/禁用的綁定

相關問題