JSFiddle - React, Tailwind, and code Playground
by nilgundag
HTML
<a data-bind="click: $root.incCounterIndirect ">Indirect does work</a>
<a data-bind="click: $root.a.incCounter ">Direct does NOT work</a>
JavaScript
function subClassA() {
this.counter = 0;
var self = this;
this.incCounter = function(){
self.counter++;
console.log("counter incs: "+self.counter);
}
}
function MainViewModel() {
this.a = new subClassA();
this.incCounterIndirect=function(){
this.a.incCounter(); // this works....
};
}
ko.applyBindings(new MainViewModel() );