Using the following simple form with a select box, the observe_field is throwing a javascript error related to the "getValue()" method in the prototype library. Any ideas as to why? Everything that I can tell is well formed syntactically. I''m running Rails 2.1.0. <% form_tag :action => :new do %> <%= select_tag ''transaction_type'', "<option></option><option>Tuition Reimbursement</option><option>Schools & Seminars</option>" %><br /><br /> <%= observe_field(''transaction_type'', :url => { :action => "display_alternate_fields" }, :update => "transaction_specific", :with => "''transaction_type='' + encodeURIComponent(value)") %> <div id="transaction_specific"> </div> <div><%= submit_tag "Create" %></div> <% end %> The error points to the following line (-->) within the serialize portion of "Form.Element.Methods" in "prototype.js": getValue: function(element) { element = $(element); var method = element.tagName.toLowerCase(); --> return Form.Element.Serializers[method](element); }, -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2008-Nov-05 12:46 UTC
Re: observe_field with select throwing javascript error
Corey Murphy wrote:> Using the following simple form with a select box, the observe_field is > throwing a javascript error related to the "getValue()" method in the > prototype library. Any ideas as to why? Everything that I can tell is > well formed syntactically. I''m running Rails 2.1.0. > > <% form_tag :action => :new do %> > <%= select_tag ''transaction_type'', "<option></option><option>Tuition > Reimbursement</option><option>Schools & Seminars</option>" %><br /><br > /> > > <%= observe_field(''transaction_type'', > :url => { :action => "display_alternate_fields" }, > :update => "transaction_specific", > :with => "''transaction_type='' + encodeURIComponent(value)") > %> > > <div id="transaction_specific"> </div> > <div><%= submit_tag "Create" %></div> > <% end %>The problem is that "value" is not defined in this context. You should be able to just eliminate the :with option. -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Nov-05 13:01 UTC
Re: observe_field with select throwing javascript error
On 5 Nov 2008, at 12:46, Mark Reginald James wrote:> > Corey Murphy wrote: >> Using the following simple form with a select box, the >> observe_field is >> throwing a javascript error related to the "getValue()" method in the >> prototype library. Any ideas as to why? Everything that I can >> tell is >> well formed syntactically. I''m running Rails 2.1.0. >> >> <% form_tag :action => :new do %> >> <%= select_tag ''transaction_type'', "<option></option><option>Tuition >> Reimbursement</option><option>Schools & Seminars</option>" %><br / >> ><br >> /> >> >> <%= observe_field(''transaction_type'', >> :url => { :action => "display_alternate_fields" }, >> :update => "transaction_specific", >> :with => "''transaction_type='' + encodeURIComponent(value)") >> %> >> >> <div id="transaction_specific"> </div> >> <div><%= submit_tag "Create" %></div> >> <% end %> > > The problem is that "value" is not defined in this context. > > You should be able to just eliminate the :with option.That''s not actually true. The with clause is evaluated in a context where value is defined. Are there any other objects on the page with id transaction_type ? (or to put things another way, if you evaluate $(''transaction_type'') in the firebug console, what do you get?) Fred> > > -- > Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Corey Murphy
2008-Nov-05 15:07 UTC
Re: observe_field with select throwing javascript error
> Are there any other objects on the page with id transaction_type ? (or > to put things another way, if you evaluate $(''transaction_type'') in > the firebug console, what do you get?) > > FredYou nailed it Fred. I had stripped out the rest of the page to simplify what was going on to see if there were any other underlying objects getting in the way and there was another <div> on the page with an id of "transaction_type". Once I removed it, everything worked fine. Thanks again, -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---