Let's say I have a very simple PrototypeJS class that looks like this:
var Foo = Class.create({
initialize: function() {
this.bar = 'bar';
},
dostuff: function() {
$$('.enabled').each( function(elem) {
alert(this.bar); //FAIL
});
}
});
This fails because the function being passed to .each() doesn't have any idea what this refers to.
How can I access the bar attribute of the Class from inside that function?