hi,
I have problems with binding and this references in a function. i.e
using two different this reference in a function . Here is the case:
var myNewClass = new Class({
options: {
/*bla bla*/
},
initialize: function(){
this.togglers = $$('ul');
this.togglers.addEvent('click',function(){
var childContainer= this.parentNode.getElement('ul');
this.myAlert(childContainer);
})
},
myAlert: function(message){
alert(message)
}
})
Browser returns an error saying this.myAlert is undefined
I know I can overcome this by using .bind(this) to addEvent function
but in this case this.parentNode becomes undefined.
in fact this references two different things for this.parentNode and
this.myAlert
I'm sure there is a simple solution for this but cant see it actually
Thanks for your help