AndreyAkinshin / knockout-mvc

Power of Knockout.js for ASP.NET MVC
http://knockoutmvc.com
203 stars 125 forks source link

Checkbox issue #7

Closed zpisgod closed 10 years ago

zpisgod commented 11 years ago

There's a model like that

...
{
  List<int> Items...
}

Then when you rendering checkboxes like that

@using(var items = ko.Foreach(m = m.Items)
{
  @items.Html.Checkbox(m => m % 2 == 0);
}

you'll get output like that

<input type="checkbox" data-bind="checked : ((parseInt() % parseInt(2)) == 0)"/>

it should be

<input type="checkbox" data-bind="checked : ((parseInt($data) % parseInt(2)) == 0)"/>

So, I have to use it like that:

@using(var items = ko.Foreach(m = m.Items)
{
  @items.Html.Checkbox(m => "$data % 2 == 0");
}

It works as expect but it's not grace...