質問

I'm trying to figure out how to disable an Html.Checkbox with the given syntax:

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

Knockout code:

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; 
 }

Please help

役に立ちましたか?

解決

data-bind='enable : isEnabled'

You want to test if this checkbox is supposed to be enabled. I don't know your criteria for being enabled, but here is the binding for enable/disable

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top