One last tip: It's a good practice when coding classes to always have "this"
point to the instance of the class. That is to say, if you have a function
inside a class that is, say, an event handler for an element, you don't want
to refer to the element as "this" as it gets confusing; in a class "this" is
always the instance. It's usually not a problem as you often have a pointer
to the OTHER thing. Example:
var MyClass new Class({
initialize: function(element){
element.addEvent('click', function(){
this.setStyle('color', 'red'); //here "this" points to the element,
and can catch you of guard
element.setStyle('color', 'red'); //much better; you don't need to
use "this" here because you already have a pointer to the element
});
}
});
On Sat, Apr 30, 2011 at 12:41 PM, Tim Wienk <[email protected]> wrote:
> On Sat, Apr 30, 2011 at 20:56, אריה גלזר <[email protected]> wrote:
> > I haven't noticed anyone else pointing this out, but instead of doing:
>
> I think he uses MooTools 1.1, since he also uses `new Event(e).stop()`
> to stop an event's default and propagation. :-D
>
>
> --
> Tim Wienk, Software Developer, MooTools Developer
> E. [email protected] | W. http://tim.wienk.name
>