Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the checked binding in knockout with a list of checkboxes checks all the checkboxes

Tags:

knockout.js

I have a problem when binding a list of complex values (id/ description) to a list of checkboxes.

The problem is that I need not just the id or the description, but both.

When I bind using the Checked binding, all the checkboxes in my list are checked when I click one item.

This is part of something bigger, and the reason I want the object and not just the id is that the complex type in turn will have a list which I want to bind to another list of checkboxes.

Here is a fiddle that produces the problem: http://jsfiddle.net/M8KFd/1

Thankful for your help.

like image 818
Mikael Östberg Avatar asked Nov 18 '11 10:11

Mikael Östberg


1 Answers

I track the state of each item individually, then get the selected items using a dependent observable something like this

like image 138
Richard Friend Avatar answered Sep 19 '22 01:09

Richard Friend