On Feb 13, 11:39 pm, Enzo Rivello
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Hi there!
>
> I need to use observe field to change dynamically one select field based
> on another select field:
>
> here is the view:
>
> <%= observe_field ''class'', :url => { :action =>
''update_list'' },
> :frequency => 0.25,
> :update => ''nickname'',
> :with => ''tipid''
> %>
>
> Class:<select name="<%= "#{name}[][#{name}_class]"
%>" id="class">
> <%= options_from_collection_for_select(Tiprod.find(:all),
> "id","name", {:include_blank => true}) %>
> </select>
> Name:<select name="<%= "#{name}[][#{name}_data]"
%>" id="nickname">
> <option></option>
> </select>
>
> here is the controller
>
> def update_list
> @tipid = params[:tipid]
> @products = Specprod.find(:all, :conditions => [''tiprif LIKE
?'',
> "%{@tipid}%"])
> end
>
> and here is the update_list.rhtml
>
> <% for product in @products%>
> <option value="<%= product.id %>"><%=
product.name%></option>
> <% end %>
>
> inspired
by:http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-...
>
The observe_field helper just produces some javascript that does stuff
to the element with id class
You''ve got the call to observe_field before your select element, ie
it''s trying to observe something that doesn''t exist yet.
Fred
> Now, when i try to fire this application, the script doesn''t work,
and
> the JS console tell me "Element is null" .
> Why?Where i was wrong?
>
> thanks in advance for the help
> --
> Posted viahttp://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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---