mocambo
2008-Jun-16 03:33 UTC
prototype Element.observe handler function - how to add more arguments in addition to event handler ?
$(id).observe(''click'', this.add( ''name'' ).bindAsEventListener(this)); As we know, event handler passed as argument to handler function. Sample above not correct, but how to add ''name'' string argument to handler function? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
developer-P5Ep+WoDybrQT0dZR+AlfA@public.gmane.org
2008-Jun-16 05:05 UTC
Re: prototype Element.observe handler function - how to add more arguments in addition to event handler ?
mocambo wrote:> $(id).observe(''click'', this.add( ''name'' ).bindAsEventListener(this)); > > As we know, event handler passed as argument to handler function. > Sample above not correct, but how to add ''name'' string argument to > handler function?If you have 1.6, you can do $(id).observe(''click'', this.add.bind(this, ''name'')); This will put ''name'' in the first parameter to this.add(). --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I. E. Smith-Heisters
2008-Jun-16 18:31 UTC
Re: prototype Element.observe handler function - how to add more arguments in addition to event handler ?
On Jun 15, 10:05 pm, develo...-P5Ep+WoDybrQT0dZR+AlfA@public.gmane.org wrote:> mocambo wrote: > > $(id).observe(''click'', this.add( ''name'' ).bindAsEventListener(this)); > > > As we know, event handler passed as argument to handler function. > > Sample above not correct, but how to add ''name'' string argument to > > handler function? > > If you have 1.6, you can do > > $(id).observe(''click'', this.add.bind(this, ''name'')); > > This will put ''name'' in the first parameter to this.add().http://www.prototypejs.org/api/function Function.curry may also be helpful. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---