Maybe you could just write how I should do that in this case...!

On 16 Mai, 14:43, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> OK, I understand the problem itself but am not able to use the
> bindAsEventListener-Method.
> I tried that:
> onSuccess: this.FormSubmitSuccess.bindAsEventListener(this)
> but that doesn't work. Why?
>
> On 16 Mai, 14:18, "T.J. Crowder" <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > "You must remember 
> > 'this'..."http://blog.niftysnippets.org/2008/04/you-must-remember-this.html
>
> > The short version for Prototype users is:  Use bind() or
> > bindAsEventLister():http://www.prototypejs.org/api/function#method-bindhttp://www.prototy...
>
> > ...but I think the post is worth a read as it discusses *why* you need
> > to use them...
>
> > Hope this helps,
> > --
> > T.J. Crowder
> > tj / crowder software / com
>
> > On May 16, 1:12 pm, "[EMAIL PROTECTED]"
>
> > <[EMAIL PROTECTED]> wrote:
> > > Hello,
>
> > > I have an Object which looks like that:
>
> > > var Newsletterform = Class.create ({
>
> > >         /**
> > >          * kontructor
> > >          */
> > >         initialize: function (id_form, id_container)
> > >         {
> > >                 this.form = $(id_form);
> > >                 this.container = $(id_container);
> > >                 Element.show (this.container);
> > >                 Event.observe(this.form, "submit", this.FormSubmit, 
> > > false);
> > >         },
>
> > >         /**
> > >          * Ajax-Success-Handler
> > >          */
> > >         FormSubmitSuccess: function (resp, jsonObj)
> > >         {
> > >                 alert ('bin hier!');
> > >                 window.alert (resp);
> > >         },
>
> > >         /**
> > >          * Event-Handler
> > >          * Called, when user clicks submit
> > >          */
> > >         FormSubmit: function ()
> > >         {
> > >                 new Ajax.Request (AjaxApi, {
> > >                         onSuccess: this.FormSubmitSuccess,                
> > >    <----
> > > here!!!!!!
> > >                         parameters: Form.serialize('newsletterform') + 
> > > '&cat=1&a=1',
> > >                         method: 'get',
> > >                         onFailure: function (resp) {
> > >                                 alert ('Error!');
> > >                         }
> > >                 });
> > >         }
>
> > > });
>
> > > I call this object like this:
> > > handler = new Newsletterform ('newsletterform',
> > > 'newsletterform_container');
>
> > > Now I have trouble with the line marked by "<---- here!!!!!!". When I
> > > replace the "this" by "handler" the "FormSubmitSuccess"-function is
> > > called. Otherwise it doesn't work. I know (or guess) that it's the old
> > > scope-problem with javascript but I don't know how to fix it in this
> > > case. I don't want to use handler because the instance-name could
> > > change..
>
> > > I would be happy to get some help with that!
> > > M. Hoffmann
--~--~---------~--~----~------------~-------~--~----~
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 rubyonrails-spinoffs@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to