This project is read-only.


Topics: Language Specification
Oct 3, 2012 at 9:28 AM

I'm not sure if this is bug or it was planed. But it would be nice to have auto scope when we are binding events. 
Code example will generate an error then we click the button.  Of corse solution for this problem is using $().proxy function. But it don't sound very comfortably  it just required from developer extra work. 
In short word i would love to this been always and instance of the class we are in. 


Oct 4, 2012 at 5:11 AM

I'm unable to get the picture to load.  Can you cut/paste code to see what you are referring to?

I'm not 100% clear from the text in the initial description, but I believe using the fat arrow syntax, i.e. "window.someevent = (evt) => { /* body */; }" may resolve the issue you refer too.  If not, please expand further on your description.

Oct 4, 2012 at 6:30 AM

Hey, Thanks for answer. 

This is the link to problem which I describe 

The thing the I expect is that if i bind the member of the class to the event I would like to have in the binded method The class scope not the event scope. Is this clear ?

Oct 4, 2012 at 12:07 PM
Edited Oct 4, 2012 at 12:08 PM

Instead of

    button.onclick = this.alert;

I would suggest you write

    button.onclick = () => this.alert();

or just inline the method

    button.onclick = () => alert(this.greet());