When you assign a function to an Ajax event: { ... onComplete: showInfo } I see that the Ajax object is passed into the showInfo function, but how would I pass in additional variables I''ll need, or can I custom define what I''ll need in the Ajax options hash and access it that way? Thank you Daniel
Just proxy the function with a closure : { onComplete: function(ajaxObj) { showInfo(ajaxObj,anotherParam1,anotherParam2) } } HTH Matt Daniel Elmore wrote: > When you assign a function to an Ajax event: > > { ... onComplete: showInfo } > > I see that the Ajax object is passed into the showInfo function, but how > would I pass in additional variables I''ll need, or can I custom define > what > I''ll need in the Ajax options hash and access it that way? > > Thank you > Daniel > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
Daniel Elmore wrote:> When you assign a function to an Ajax event: > > { ... onComplete: showInfo } > > I see that the Ajax object is passed into the showInfo function, but how > would I pass in additional variables I''ll need, or can I custom define what > I''ll need in the Ajax options hash and access it that way?The options hash could be used to piggy-back your own options although the closure method described by Matt seems like a less fragile method. Eric
Thanks Matt and Eric, it''sa working. -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Eric Anderson Sent: Tuesday, August 08, 2006 7:43 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] Re: Easy Ajax.Request Question Daniel Elmore wrote:> When you assign a function to an Ajax event: > > { ... onComplete: showInfo } > > I see that the Ajax object is passed into the showInfo function, but how > would I pass in additional variables I''ll need, or can I custom definewhat> I''ll need in the Ajax options hash and access it that way?The options hash could be used to piggy-back your own options although the closure method described by Matt seems like a less fragile method. Eric _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs