I have a problem programming object-oriented in Javascript. I have the following:
class Foo{
constructor(){...}
...
a_needed_method(){...}
...
a_method(){
...
jsObject.on("click",function(params){
this.a_needed_method();
});
}
}
The problem is, if I call the a_needed_method
method using this
there, then this
is referencing the anonymous function that controls the onclick
event. How I can call a_needed_method()
from this anonymous function?