I'm trying to send class property as parameter to addEventListener. Doing this is because when the event occurs, I'm no longer in the context of the class (this) and can't get\set the value of the property. I need somehow pass a reference of the property to the function. I'm aware that I can add the property as attribute to the event target and reach it like this, but I quite sure that there should be a more straight forward solution. This is the relevant code:
export class ZZZZZ{
constructor()
{
this.activeTooltip = null; //This is the relevant property
}
YYYYFunc()
{
/*thinking of doing it like that*/
var activeTooltip = this.activeTooltip;
cancelDiv.addEventListener('click', function() { XXXFunc(activeTooltip)});
}
XXXFunc(activeTooltip)
{
var A = this.activeTooltip; //I'm not in the context of the class -
//"this" is irrelevant - it is null
var B = activeTooltip;
}