title: KnockoutJS Binding Issue - Cannot read property
body: <p>I have what is likely a simple Knockout question but I'm a complete beginner with it.  I was tossed this page of code that someone else has worked on but never finished.</p>
  
  <p>When this page first loads, the data is retrieved and the main grid loads properly.  The problem comes in when I attempt to auto-select the first record in the results so that a detail list gets filled out below the grid.  </p>
  
  <p>When that happens, I receive the following message.</p>
  
  <p><strong>Uncaught TypeError: Unable to process binding "text: function (){return selected.RequestLog.Timestamp }" , Message: Cannot read property 'Timestamp' of undefined</strong></p>
  
  <p>Here is the code snippets with which I'm working.  The data coming back is from Entity Framework.</p>
  
  <pre><code>var siteLogModel = function () {
              var self = this;
  
              self.errorList = ko.observableArray([]);
              self.selected = ko.observable();
  
              self.updateErrorList = function (page) {
                  jQuery.ajax({
                      type: "POST",
                      url: "/Admin/ErrorPage",
                      data: { pageNum: page },
                      success: function (result) {
                          self.errorList(result);
                          self.selected(result[0]);
  
                          // Since we have success, add the click handler so we can get the details about a row by id.
                          //addRowHandlers();
                      },
                      error: function (result) {
                          jQuery("#status").text = result;
                      }
                  });
              };
          };
  </code></pre>
  
  <p>This is the actual binding that tries to happen after the data is loaded.  RequestLog does not seem to exist at binding time, even though it <strong>does</strong> seem to be ok if I set a breakpoint in the above function on the line self.selected(result[0]).  </p>
  
  <p>I think this is a scope problem but I can't for the life of me think of how best to fix it.  Any help would be appreciated.</p>
  
  <pre><code>    &lt;div class="param"&gt;
         &lt;span&gt;Time&lt;/span&gt;
         &lt;label data-bind="text: selected.RequestLog.Timestamp"&gt;&lt;/label&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>UPDATE:  Here is the document ready portion.</p>
  
  <pre><code>jQuery(document).ready(function () {
  
              var vm = new siteLogModel();
              vm.updateErrorList(0);
              ko.applyBindings(vm);
          });
  </code></pre>