Geek Speak: GWT-Ext and Grails just works!: «Tuesday, December 25, 2007»
Mootools – Using .bind(this)
From MooTools Users | Google Groups
#############
var toto = new Class ({
Implements: Options,
options: {
message: "toto"
},
initialize: function(elem, options){
this.setOptions(options);
this.alternateMessage = "a message";
this.elem = elem;
this.elem.addEvent('click', function(){
this.alternateMessage = "other message";
this.aMethod();
}.bind(this));
},
aMethod: function(){
alert(this.options.message);
}
});
##################
in this class, you can see two effects of this binding in this
function
this.elem.addEvent('click', function(){
this.alternateMessage = "other message";
this.aMethod();
}.bind(this));
– this.alternateMessage is now changed for the whole class, not only
inside the fucntion as this refers to the class
– without binding the click function with .bind(this) the result would
be «this.alternateMessage has no properties», «this.aMethod() is not a function»
binding the function to the class (this) allows it to use any method
or this.var set inside it
How to Create a Super Shiny Pencil Icon – PSDTUTS
How to Create a Super Shiny Pencil Icon – PSDTUTS: «How to Create a Super Shiny Pencil Icon»
10 paquetes de iconos para escritorio Ubuntu/Gnome » RibosoMatic
10 paquetes de iconos para escritorio Ubuntu/Gnome » RibosoMatic: «10 paquetes de iconos para escritorio Ubuntu/Gnome»
200+ Photoshop Brushes for Light, Sparkles, Glows and Glitter | Vandelay Website Design
200+ Photoshop Brushes for Light, Sparkles, Glows and Glitter | Vandelay Website Design: «200+ Photoshop Brushes for Light, Sparkles, Glows and Glitter»
Illustrating a Cool Glass of Beer – PSDTUTS
Illustrating a Cool Glass of Beer – PSDTUTS: «Illustrating a Cool Glass of Beer»