So, I have this:
function foo(){
var that = this;
this.elements = [
$bar = $('.bar'),
$foo = $('.foo')
];
this.example = function(){
alert("a");
}
this.elements.$bar.on('click', that.example);
}
and it's not working, however if I change this line:
this.elements.$bar.on('click', that.example);
for this one:
this.elements.$bar.on('click', function(){ that.example() });
That is, wrapping the method into an anonymous function, it does work...
EDIT: It also works if the method is not within the constructor function..