MrBanabas-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2007-Sep-17 10:33 UTC
observe_field and :function
Hi, I m using the observe_field helper with the :function attribute. If I do the following everything it works without any issue: <%= observe_field ''select_gender'', {:function => "(value == ''2'') ? $(''record_ohrmarke'').value = ''a boy'': $(''record_ohrmarke'').value = ''a girl'';"} %> I would like to perform a more complicated processing and I thought it would be nice to do something like that: <script type="text/javascript"> function handle_gender_change(element, value) { (value == ''2'') ? $(''record_ohrmarke'').value = ''ein Maedchen'': $(''record_ohrmarke'').value = ''ein Bub''; }; </script> ..... .... <%= observe_field ''select_gender'', {:function => "handle_gender_change(element,value);"} %> However, that results in an js error telling me that handle_gender_change is not defined... Would be great if somebody could help me out here with the correct way. thanks a lot in advance. -- volker --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
MrBanabas-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2007-Sep-21 11:55 UTC
Re: observe_field and :function
Hi, well, just to give myself a response... :-) I was nt able to get it up and running with "infile" javascript. But if I place the function in a normal .js file everything is working fine. -- Volker On 17 Sep., 12:33, "MrBana...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org" <MrBana...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi, > > I m using the observe_field helper with the :function attribute. > > If I do the following everything it works without any issue: > > <%= observe_field ''select_gender'', {:function => "(value == ''2'') ? > $(''record_ohrmarke'').value = ''a boy'': > $(''record_ohrmarke'').value = ''a girl'';"} %> > > I would like to perform a more complicated processing and I thought it > would be nice to do something like that: > > <script type="text/javascript"> > function handle_gender_change(element, value) > { > (value == ''2'') ? > $(''record_ohrmarke'').value = ''ein Maedchen'': > $(''record_ohrmarke'').value = ''ein Bub'';}; > > </script> > ..... > .... > > <%= observe_field ''select_gender'', {:function => > "handle_gender_change(element,value);"} %> > > However, that results in an js error telling me that > handle_gender_change is not defined... > > Would be great if somebody could help me out here with the correct > way. > > thanks a lot in advance. > > -- > volker--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---