I am using knockout and have an array "Properties" and each "Property" can have child "properties"
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"
I've tried to get this to work by using creating a computed, eg.
this.TabID = ko.computed(function(){
return $parent.TabID();
});
and then realised that $parent was only available within the foreach loop
I've also tried passing the parent through to in the constructor eg
var childproperty = function(parent,[other properties]){
this.TabID = ko.computed(function(){
return parent.TabID(); // OR return parent.TabID;
}
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
that is each parent property should be properties[i].propitem where i = a computed value based on each parent + their child properties
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
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.
Cheers.