title: Binding a list of objects to a list of checkboxes
body: <p>I have a list of objects, each with a few fields, like this:</p>
  
  <pre><code>function Person(id,name,age) {
      this.id = id;
      this.name = name;
      this.age = age;
  }
  
  var listOfPeople = [
      new Person(1, 'Fred', 25),
      new Person(2, 'Joe', 60),
      new Person(3, 'Sally', 43)
  ];
  
  var viewModel = {
      this.people = ko.observableArray(listOfPeople);
      this.selectedPeople = ko.observableArray([]);
  }
  </code></pre>
  
  <p>I would like to build a list of checkboxes, one for each person, something along these lines:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;ul data-bind="foreach: people"&gt;
      &lt;li&gt;
          &lt;input type="checkbox" data-bind="value: id, checked: ?"&gt;
          &lt;span data-bind="name"&gt;&lt;/span&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>My confusion is that in the checkbox <code>data-bind</code> attribute, I would like to refer to both the object being selected (that is, the <code>person</code> or the person's <code>id</code>), as well as to the list of all selected people. How do I refer to that in the scope of the <code>foreach</code> binding?</p>
  
  <p>I guess a corollary is: how do I refer to the object being bound? Here "<code>this</code>" seemed to be bound to the window, not to the object. </p>
  
  <p>The example of the "<a href="http://knockoutjs.com/documentation/checked-binding.html" rel="noreferrer"><code>checked</code> binding on the knockoutjs site</a>" deals with primitives and uses a named template. I am confused about how to do this with objects and with anonymous templates.</p>