Hi, I would like to know (if it is possible) how to pass parameters to a function in Event.observe Example : Event.observe(tag_id, "change", myfunction, false); The function myfunction should have a specific behavoir according to parameters : function myfunction(param1, param2); Thank you. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Peters
2007-Nov-02 16:14 UTC
Re: How to pass parameters to a function in Event.observe
nicotux wrote:> I would like to know (if it is possible) how to pass parameters to a > function in Event.observe > > Example : > Event.observe(tag_id, "change", myfunction, false); > > The function myfunction should have a specific behavoir according to > parameters : > function myfunction(param1, param2);This is what a closure is for. Event.observe(tag_id, "change", function() { myfunction(param1, param2) }, false) -- Michael Peters Developer Plus Three, LP --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Trevan Richins
2007-Nov-02 16:34 UTC
Re: How to pass parameters to a function in Event.observe
Michael Peters wrote:> nicotux wrote: > > >> I would like to know (if it is possible) how to pass parameters to a >> function in Event.observe >> >> Example : >> Event.observe(tag_id, "change", myfunction, false); >> >> The function myfunction should have a specific behavoir according to >> parameters : >> function myfunction(param1, param2); >> > > This is what a closure is for. > > Event.observe(tag_id, "change", function() { myfunction(param1, param2) }, false) > > >In 1.6, you could also use the new curry function: Event.observe(tag_id, ''change'', myfunction.curry(param1, param2), false); --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Ok, thank you very much ! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Richard Quadling
2007-Nov-05 12:15 UTC
Re: How to pass parameters to a function in Event.observe
On 02/11/2007, nicotux <nicotux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Ok, thank you very much ! >Ditto.> > > >-- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---