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 [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
-~----------~----~----~----~------~----~------~--~---

Reply via email to