OH ok, I guess I just had that fundamental misunderstanding.
On May 30, 1:10 am, RobG <[EMAIL PROTECTED]> wrote:
> On May 30, 5:52 pm, eggie5 <[EMAIL PROTECTED]> wrote:
>
>
>
> > I'm using the prototype Ajax.Request with an anonymous functions
> > inside of a javascript object. However, once I get into the anonymous
> > function of the Ajax.Request onSuccess, I loose the bindng to my
> > object and this now refers to window instead of my object.
>
> > How can I maintain binding from within the anonymous function?
>
> > Code snippet:
>
> > CampaignView.prototype.DataBind=function(event)
> > {
> > var c=this; //binding is still good - refers to CampaignView
> > object
>
> > new Ajax.Request('url.aspx',
> > {
> > method: 'post',
> > onSuccess: function(resp)
> > {
> > var d=this; //binding is lost - refers to window
>
> What "binding"? The value of a function's this keyword is set by the
> calling function. It will be one of: the object that the function is
> called as a method of, whatever is set using call() or apply(), or the
> window object.
>
> What do you want it to refer to?
>
> --
> Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---