I can't seem to find around a way to resolve one apparently simple task. I've made a simple Js class, let's say:
class MyClass{
constructor() {
this.myProperty = 10;
}
init(){
$(".my-items").on('click',this.myMethod);
}
myMethod(){
// How do i access both this.myProperty and $(this) to have the current called jQuery object?
}
}
If i want to access this.myProperty
i have to use:
$(".my-items").on('click',this.myMethod.bind(this));
but if i do that i lose access to $(this)
which would give the jQuery object on which the click event was triggered.
How am i supposed to keep reference to both "this"? because that's what i would need like 90% of the times