Reputation: 1057
I have Html written in Razor syntax:
@for (var i = 0; i < Model.AllBetStatuses.Count; ++i)
{
<li class="betReportingCheckbox">
@Html.CheckBoxFor(m => m.AllBetStatuses[i].Checked, new { @class =
"betStatusCheckboxes"})
@Html.DisplayFor(m => m.AllBetStatuses[i].Name)
@Html.HiddenFor(m => m.AllBetStatuses[i].Value)
</li>
}
I want to use knockout.js to bind these values, but when I try something of this type:
@Html.CheckBoxFor(m => m.AllBetStatuses[i].Checked, new { @class =
"betStatusCheckboxes", @data-bind="..."})
I get a syntax error, because the '-' character is not valid there. Is there any simple way to do this using Razor syntax?
Upvotes: 5
Views: 9098
Reputation: 8987
Replace the '-' by an '_'
@Html.CheckBoxFor(m => m.AllBetStatuses[i].Checked, new { @class =
"betStatusCheckboxes", @data_bind="..."})
I hope it helps.
Upvotes: 16