title: Knockout text binding not working for input
body: <p>As a total beginner with Javascripts I decided to try out Knockout starting very simple and going more advanced. I however couldn't even manage to get it to work in a very simple scenario.</p>
  
  <p>I'm guessing the problem is something very simple and I'm kind of embarrassed to be asking this here. But I'm not good at debugging Javascript and do not know how bugs might manifest so here goes.</p>
  
  <p>This is the html source of the page after it's been generated by asp.net MVC 3 :</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;head&gt;
      &lt;title&gt;Index&lt;/title&gt;
      &lt;link href="/Content/Site.css" rel="stylesheet" type="text/css" /&gt;
      &lt;script src="/Scripts/jquery-1.5.1.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;h2&gt;Index&lt;/h2&gt;
  
  &lt;script src="/Scripts/knockout-1.3.0beta.debug.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="/Scripts/knockout-1.3.0beta.js" type="text/javascript"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  
      var viewModel = {
          name: "Joe",
          number: "13"
      };
  
  &lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
      ko.applyBindings(viewModel);
  &lt;/script&gt;
  
  &lt;ul&gt;
  &lt;li&gt;Name: &lt;input data-bind="text: name"/&gt;&lt;/li&gt;
  &lt;li&gt;Number: &lt;input data-bind="text: number"/&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;ul&gt;
  &lt;li&gt;Name: &lt;span data-bind="text: name"&gt;&lt;/span&gt;&lt;/li&gt;
  &lt;li&gt;Number: &lt;span data-bind="text: number"&gt;&lt;/span&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Joe or 13 does not get bound to the input or textbox.</p>
  
  <p>Tried putting it in a ko.observable() but also deos not work. It's just like the script isn't running.</p>
  
  <p>Tried debugging using FireBug and I can see the applyBinding is executed and the viewModel object does include the correct variables.</p>
  
  <p>It's probably something obvious that is going on here. If you can't see it here then could you point out what I should look for when using FireBug?</p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>After trying several combinations of the solutions given I'm still having problems. With one solution the HTML looks like this:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  
      &lt;title&gt;Index&lt;/title&gt;
  
      &lt;link href="/Content/Site.css" rel="stylesheet" type="text/css" /&gt;
      &lt;script src="/Scripts/jquery-1.5.1.min.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="/Scripts/knockout-1.3.0beta.debug.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
              var viewModel = {
                  name: ko.observable("Joe"),
                  number: ko.observable("13")
              };
      &lt;/script&gt;
  
      &lt;script type="text/javascript"&gt;
          $(function () { ko.applyBindings(viewModel); })
      &lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;h2&gt;Index&lt;/h2&gt;
  
  &lt;ul&gt;
  &lt;li&gt;Name: &lt;input data-bind="text: name"&gt;&lt;/input&gt;&lt;/li&gt;
  &lt;li&gt;Number: &lt;input data-bind="text: number"&gt;&lt;/input&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;ul&gt;
  &lt;li&gt;Name: &lt;span data-bind="text: name"&gt;&lt;/span&gt;&lt;/li&gt;
  &lt;li&gt;Number: &lt;span data-bind="text: number"&gt;&lt;/span&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Doesn't seem to matter which applyBindings solution I use they all work the same.</p>
  
  <p>So the binding finally works but only on IE and Firefox but not on Chrome. Also the observable doesn't work at all. I can't update the fields by writing into the input field.</p>