title: How can I access a parent variable from a child array using knockout js
body: <p>I am using knockout and have an array "Properties" and each "Property" can have child "properties"</p>
  
  <p>all is fine except that there is a property of the array "TabID" that should be inherited - for example if it is changed on the parent "Property" it should also change on the child "Property"</p>
  
  <p>I've tried to get this to work by using creating a computed, eg.</p>
  
  <pre><code>this.TabID = ko.computed(function(){
  return $parent.TabID();
  });
  </code></pre>
  
  <p>and then realised that $parent was only available within the foreach loop</p>
  
  <p>I've also tried passing the parent through to in the constructor eg</p>
  
  <pre><code>var childproperty = function(parent,[other properties]){
  this.TabID = ko.computed(function(){
  return parent.TabID(); // OR return parent.TabID;
  }
  </code></pre>
  
  <p>could somebody point me in the right direction please? As a side note I also need to be able access the parent for a zero based [i] caclulation</p>
  
  <p>that is each parent property should be properties[i].propitem where i = a computed value based on each parent + their child properties</p>
  
  <p>for example: if parent property 1 has 3 child properties, then parent property 1 should be i=0, childproperties (i=1,2,3) and then parent property 2 would have an "i" of 4</p>
  
  <p>I know... I don't ask for much right, I'm not expecting a perfect solution for my issues but if somebody can at least point me in the right direction I would be very grateful.</p>
  
  <p>Cheers.</p>