I need to observe the value of several form fields with the same callback. With prototype I''m just using: new Form.Element.Observer(id1,1,callback); new Form.Element.Observer(id2,1,callback); new Form.Element.Observer(id3,1,callback); new Form.Element.Observer(id4,1,callback); Anyway to tie those into one Observer or make this more efficient? Thanks, Daniel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Daniel Eben Elmore a écrit :> I need to observe the value of several form fields with the same callback. > With prototype I''m just using: > > new Form.Element.Observer(id1,1,callback); > new Form.Element.Observer(id2,1,callback); > new Form.Element.Observer(id3,1,callback); > new Form.Element.Observer(id4,1,callback);Do you have to *exclude* other fields? If not, you could use Form.Observer. This code can''t be very much optimized from a runtime standpoint, however, it would be cleaner like this: [''id1'', ''id2'', ''id3'', ''id4''].each(function(id) { new Form.Element.Observer(id, 1, callback); }); -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Do you have to *exclude* other fields?Yeah. :)> it would be cleaner like this:Thanks for the cool tip! - Daniel -----Original Message----- From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Christophe Porteneuve Sent: Thursday, January 11, 2007 1:11 AM To: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails-spinoffs] Re: Form Element Observer - Multiple Items Daniel Eben Elmore a écrit :> I need to observe the value of several form fields with the same callback. > With prototype I''m just using: > > new Form.Element.Observer(id1,1,callback); > new Form.Element.Observer(id2,1,callback); > new Form.Element.Observer(id3,1,callback); > new Form.Element.Observer(id4,1,callback);Do you have to *exclude* other fields? If not, you could use Form.Observer. This code can''t be very much optimized from a runtime standpoint, however, it would be cleaner like this: [''id1'', ''id2'', ''id3'', ''id4''].each(function(id) { new Form.Element.Observer(id, 1, callback); }); -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---