So i have a button with this event attached:
apagar.onclick = cl.teste(this);
cl is an instance of another class , i think it doesnt matter to this case. The teste method is here:
Clinica.prototype.teste = function ()
{
alert(this.doentes.length);
}
even when i have some parameters on the function, and i set them on the onclick event, the button just does nothing. But, when i set it like this: apagar.onclick = cl.teste; it works. I need the arguement because i need the 'this' statement to work properly for the object and not for the event.
apagar.addEventListener('click', cl.teste.bind(cl), false);