Ah... That is what the glorious "bind" and "BindAsEventListener" are for
Change your onsuccess to this: onSuccess:this.handle_the_data.bind(this) More information at http://prototypejs.org/api/function smellis wrote: > Hi All, > > First off, I have to mention that I love prototype, it makes my life > so much easier and has taught me quite a few things. I am having one > problem though, how do I use Ajax.Request with in a class that I have > created? Here's a little more information: > > First an example class: > > var MyClass = Class.create(); > MyClass.prototype = { > initialize: function (element) > { > this.element = element; > this.get_some_data(); > }, > get_some_data: function () > { > new Ajax.Request('/path/to/action', {method:"get", > onSuccess:this.handle_the_data }); > }, > handle_the_data: function (t) > { > $(this.element).update(t.reponseText); > } > } > > Now, the xhtml: > > <div id="my_widget_holder"></div> > <script type="text/javascript"> > //<![CDATA[ > var widget = new MyClass('my_widget_holder'); > //]]> > </script> > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
