Hello all. I have the following snippet of code in a page of mine. As you can see it is two select boxes without a surrounding form. <div> <label for="client_selection">Filter by client</label> <%= select(''client'',''selection'', Client.find(:all, :order => ''name'').collect {|c| [ c.name, c.id ] }, :include_blank => true ) %> <label for="client_selection">Select project</label> <%= select(''project'',''selection'', Project.find(:all, :order => ''name'').collect {|p| [ p.name, p.id ] }, :include_blank => true ) %> </div> I am trying to setup an observer on the first field using the following: <%= observe_field("client_selection", :update => "project_selection", :url => {:action => :reload_projects}, :with => "''id=''+escape(value)") %> The idea is that when the user selects a client only the client''s projects are displayed as options in the second select box. However I am coming across a JavaScript error. Not knowing much about JavaScript (Not enough to dbug prototype.js anyway!) I am rather stuck. FireBug gives me the following javascript trace: element has no properties prototype.js?1159... (line 1506) anonymousprototype.js?1159... (line 1506) anonymousprototype.js?1159... (line 1658) anonymousprototype.js?1159... (line 1615) anonymousprototype.js?1159... (line 20) nullhttp://localhost:... (line 14) As far as I can see I haven''t done anything totally out of whack on the RoR side. I am running on Edge Rails so am not sure if it is me or an issue in Edge (Or prototype.js). Any help would be much appreciated. RJ -- 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 -~----------~----~----~----~------~----~------~--~---
Can you post the resulting action and RJS code? It looks like you''re referencing a DOM element that doesn''t exist (misspelled?). Jason On 10/12/06, RJ <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hello all. > > I have the following snippet of code in a page of mine. As you can see > it is two select boxes without a surrounding form. > > <div> > <label for="client_selection">Filter by client</label> > <%= select(''client'',''selection'', Client.find(:all, :order => > ''name'').collect {|c| [ c.name, c.id ] }, :include_blank => true ) %> > <label for="client_selection">Select project</label> > <%= select(''project'',''selection'', Project.find(:all, :order => > ''name'').collect {|p| [ p.name, p.id ] }, :include_blank => true ) %> > </div> > > I am trying to setup an observer on the first field using the following: > > <%= observe_field("client_selection", :update => "project_selection", > :url => {:action => :reload_projects}, :with => "''id=''+escape(value)") > %> > > The idea is that when the user selects a client only the client''s > projects are displayed as options in the second select box. However I am > coming across a JavaScript error. Not knowing much about JavaScript (Not > enough to dbug prototype.js anyway!) I am rather stuck. FireBug gives me > the following javascript trace: > > element has no properties > prototype.js?1159... (line 1506) > anonymousprototype.js?1159... (line 1506) > anonymousprototype.js?1159... (line 1658) > anonymousprototype.js?1159... (line 1615) > anonymousprototype.js?1159... (line 20) > nullhttp://localhost:... (line 14) > > As far as I can see I haven''t done anything totally out of whack on the > RoR side. I am running on Edge Rails so am not sure if it is me or an > issue in Edge (Or prototype.js). > > Any help would be much appreciated. > > RJ > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Jason Roelofs wrote:> Can you post the resulting action and RJS code? It looks like you''re > referencing a DOM element that doesn''t exist (misspelled?). > > JasonHi Jason. this is the first time I have used field observers and RJS so I haven''t written the resulting action yet. The first step was to get the observer working and contacting the server. Currently it isn''t calling the server when the field changes. I assume that I don''t have to worry about the resulting action until I can verify that the server action is being called. If not then I''ll get to it. Thanks RJ -- 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 -~----------~----~----~----~------~----~------~--~---
Hmm, it looks ok, though the :with syntax may be a problem. For the record, you don''t need :with if it''s dealing with just a field, Rails knows what you''re trying to do. Can you post the resulting HTML? That will help solve this. Jason On 10/12/06, RJ <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Jason Roelofs wrote: > > Can you post the resulting action and RJS code? It looks like you''re > > referencing a DOM element that doesn''t exist (misspelled?). > > > > Jason > > Hi Jason. > > this is the first time I have used field observers and RJS so I haven''t > written the resulting action yet. The first step was to get the observer > working and contacting the server. > > Currently it isn''t calling the server when the field changes. > > I assume that I don''t have to worry about the resulting action until I > can verify that the server action is being called. > > If not then I''ll get to it. > > Thanks > > RJ > > -- > 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 -~----------~----~----~----~------~----~------~--~---