Reputation: 849
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
Upvotes: 0
Views: 296
Reputation: 411
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
Upvotes: 1