After looking through a few different questions regarding this topic, I'm still stumped as to how to access another function from within an object.
window.Think = {
initialize: function(){
this.currentNumber = 0;
},
updateNumber: function(){
this.currentNumber += 1;
},
listener: function(){
document.getElementById('foo').addEventListener('click', function(){
this.parent.updateNumber(); //this is where I want to call the prev function
}
}
The error I'm getting is Cannot call method 'updateNumber' of undefined
How can I call Think.updateNumber()
from within listener()
?