title: knockout unable to process binding "foreach"
body: <p>I'm new to Knockout and I'm building an app that's effectively a large-scale calculator. So far I have two instances of knockout running on one page. One instance is working perfectly fine, however the other one is entirely broken and just won't seem to register at all?</p>
  
  <p>Below is my Javascript, fetchYear is the function that works perfectly fine and fetchPopulation is the one that's completely broken. It doesn't seem to register "ageview" from the HTML at all and I can't figure out.</p>
  
  <p>The error:</p>
  
  <blockquote>
    <p>Uncaught ReferenceError: Unable to process binding "foreach: function
    (){return ageView }" Message: ageView is not defined</p>
  </blockquote>
  
  <p>Thanks in advance.</p>
  
  <p><strong>JS:</strong></p>
  
  <pre><code>var index = {
  
      fetchYear: function () {
          Item = function(year){
              var self = this;
              self.year = ko.observable(year || '');
              self.chosenYear = ko.observable('');
              self.horizon = ko.computed(function(){
                  if(self.chosenYear() == '' || self.chosenYear().horizon == undefined)
                      return [];
                  return self.chosenYear().horizon;
              });
          };
          YearViewModel = function(yeardata) {
              var self = this;
              self.yearSelect = yeardata;
              self.yearView = ko.observableArray([ new Item() ]);
              self.add = function(){
                  self.yearView.push(new Item("New"));
              }; 
          };
          ko.applyBindings(new YearViewModel(yearData));
      },
  
      fetchPopulation: function () {
          popItem = function(age){
              var self = this;
              self.age = ko.observable(age || '');
              self.chosenAge = ko.observable('');
              self.population = ko.computed(function(){
                  if(self.chosenAge() == '' || self.chosenAge().population == undefined)
                      return [];
                  return self.chosenAge().population;
              });
          };
          PopulationViewModel = function(populationdata) {
              var self = this;
              self.ageSelect = populationdata;
              self.ageView = ko.observableArray([ new popItem() ]);
              self.add = function(){
                  self.ageView.push(new popItem("New"));
              }; 
          };
          ko.applyBindings(new PopulationViewModel(populationData));
      }
  
  }
  
  index.fetchYear();
  index.fetchPopulation();
  </code></pre>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;div class="row" data-bind="foreach: yearView"&gt;
      &lt;div class="grid_6"&gt;
          &lt;img src="assets/img/index/calendar.png" width="120" height="120" /&gt;
          &lt;select class="s-year input-setting" data-bind="options: $parent.yearSelect, optionsText: 'year', value: chosenYear"&gt;&lt;/select&gt;
          &lt;label for="s-year"&gt;Start year for the model analysis&lt;/label&gt;
      &lt;/div&gt;
      &lt;div class="grid_6"&gt;
          &lt;img src="assets/img/index/clock.png" width="120" height="120" /&gt;
          &lt;select class="s-horizon input-setting" data-bind="options: horizon, value: horizon"&gt;&lt;/select&gt;
          &lt;label for="s-horizon"&gt;Analysis time horizon&lt;/label&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="row" data-bind="foreach: ageView"&gt;
      &lt;div class="grid_6"&gt;
          &lt;img src="assets/img/index/calendar.png" width="120" height="120" /&gt;
          &lt;select class="s-year input-setting" data-bind="options: ageSelect, optionsText: 'age', value: chosenAge"&gt;&lt;/select&gt;
          &lt;label for="s-agegroup"&gt;Age group of &lt;br&gt; target population&lt;/label&gt;
      &lt;/div&gt;
      &lt;div class="grid_6"&gt;
          &lt;img src="assets/img/index/clock.png" width="120" height="120" /&gt;
          &lt;input class="s-population input-setting"&gt;&lt;/input&gt;
          &lt;label for="s-population"&gt;Size of your patient &lt;br&gt; population &lt;strong&gt;National&lt;/strong&gt; &lt;/label&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>