Hi David, JavaScript handles "this" differently from other languages you may be familiar with. It's set by the calling code; it's not in any way intrinsic to the function itself.
Here are a couple of links; the first is a general (and I hope thorough) explanation of what's happening and how to deal with it; the second is a "how to" specific to Prototype (on the unofficial Prototype & script.aculo.us wiki): http://blog.niftysnippets.org/2008/04/you-must-remember-this.html http://proto-scripty.wikidot.com/prototype:how-to-hooking-events#BoundExample HTH, -- T.J. Crowder tj / crowder software / com On Jan 7, 4:24 am, David <[email protected]> wrote: > I'm having a problem where I can't access variables of the main class > from callbacks. It seems like I should have to use a keyword like > parent or something, but that didn't work. Any thoughts on this? > > //Sample Code > var Controller = Class.create({ > initialize: function() { > //This variable is the problem > this.busy = true; > new Ajax.Request(this.AJAX_SUBMIT_PAGE, > { > method:'post', > parameters: params, > onSuccess: this.HandleResponse > }); > > }, > > HandleResponse: function(transport){ > //Returns undefined > alert(this.busy); > } > > }); > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---
