On 14-Sep-06, at 8:48 PM, Juergen Schreck wrote:
> Hmmm, but if I use 'this' in lieu of 'self' in my example, I get
> errors that that this.doALotMoreStuff is not a function.
Juergen,
Here's a simpler version of your example:
var myHardWorkingObject = {
prop : "I'm doing way too much stuff!!!!",
doALotOfStuff: function () {
this.doALotMoreStuff();
},
doALotMoreStuff: function () {
alert(this.prop);
}
}
When you do:
myHardWorkingObject.doALotOfStuff();
'this' is bound the way you expect it to be. If for whatever reason
you do something like:
var shortcut = myHardWorkingObject.doALotOfStuff;
When you do:
shortcut();
'this' will not be bound the way you expect it to be.
Have a closer look at Bob's notes on this:
http://bob.pythonmac.org/archives/2005/07/06/this-sucks-in-javascript/
Beau
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---