I am having a main function and sub function inside that, like this:
var main= function () {
var self = this;
self.value1 = ko.observable("");
var data = self.value1();
self.revaluate = ko.computed(function(){
data = self.self.value1(); // i am overwriting
});
function inner(i1,i2)
{
var self= this ;
self.id1=ko.observable(i1);
self.id2=ko.observable(i2);
self.value2 = ko.observable("");
self.visibility = ko.computed(function() {
if (data == 1) {return true;}
else {false;}
});
}
}
ko.applyBindings(new main());
I need the value1
value inside my inner
function that should be dynamic.
I tried storing it in a variable and accessing it, but it's not gonna solve my case as there is a scenario where self.visibility
won't fire at all and update dynamically.
Onload I get an updated value1
so everything will work, but I have a button "goto next stage", and onclick of that button I am updating the status, i.e self.value1(2)
. At this point self.visibility
should update as there is change in value1
.
I tried to show what I need in a simple example, but in reality there's some more complex looping going on.
Any clue will be great.