title: Knockout JS - Binding to array of observable Ints
body: <p>I'm trying to bind a simple array of <strong>integers</strong> to an unordered list with inputs, like so:</p>
  
  <p>ViewModel</p>
  
  <pre><code>self.amounts = ko.observableArray();
  for (var i=0; i&lt;5; i++){
      self.amounts.push(ko.observable(i));
  }
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;ul data-bind="foreach: amounts"&gt;
      &lt;li&gt;&lt;input type="text" data-bind="value: $data"/&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>This produces the list with the inputs properly filled in with the numbers 0-4. However, when I change the value of any of the inputs the ViewModel does not get the new values. </p>
  
  <p>If I use an array of simple objects as the observableArray, like so:</p>
  
  <pre><code>[{amt: 0}, {amt: 1}, {amt: 2}]
  </code></pre>
  
  <p>and adjust the HTML to bind the input to the "amt" property, then changing the values in the inputs does trigger changes in the ViewModel.</p>
  
  <p>Is it possible to use an array of simple values and achieve two-way binding, without using a workaround that changes the original data model? If so, what am I doing wrong?</p>
  
  <p><strong>edit:</strong> this question is different than the one to which it has been marked as duplicate <a href="https://stackoverflow.com/questions/9510539/knockout-js-how-to-correctly-bind-an-observablearray">Knockout JS - How to correctly bind an observableArray</a>,
  it's about a special two-way binding case on simple type elements - <em>ints</em>, or <em>strings</em>.</p>