maximulus
2010-Mar-29 20:48 UTC
trying to update one collection_select with the selection of another
Hello,
I''ve seen numerous tutorials on this but have yet to get anything
working. It''s been about 5 days, and I am getting a little frustrated,
so here goes
Here is the model:
items has_many inventories
inventory has_many locations
locations has_many warehouses
Here is the view:
<%= javascript_include_tag :defaults %>
<% form_for (@item), :url=> {:action => "create", :id =>
@user.id} do |
i| %>
<%= i.text_field :name %>
<%= render :partial=>''getlocation'' %>
<%= submit_tag ''Submit'' %>
<% end %>
getlocation.rhtml
Location: <%= collection_select :inventory, :location_id,
@locations, :id, :streetadrees1 %>
<br>
<div id="inventory_location_id"> Warehouse location:
<%collection_select :inventory, :warehouse_id, @warehouse, :id, :name
%></div>
<%= observe_field("inventory_location_id", :frequency=>
0.025, :update => "inventory_warehouse_id", :with =>
''location_id'', :url => { :action =>
''getlocation'' } ) %>
And the controller
def new
@location= Location.find(:first,
:conditions=>[''primaryloc=?'', ''1'']
@locations = Location.find(:all)
@warehouse = Warehouse.find(:all,
:conditions=>[''location_id=?'',
@location.id])
@item = @business.items.build
end
def getlocation
@location = Location.find(params[:location_id])
@locations = Location.find(:all)
@warehouse = Warehouse.find(:all,
:conditions=>[''location_id=?'',
@location.id])
render :partial => ''getwarehouse''
end
Results: The javascript does pass to the params to the server when the
location select menu changes, but the warehouse doesn''t seem to
collect the new data, and update its list. Any ideas? Thanks in
advance. (and yes, I need to use observe field, a totally client side
solution will not work for my purposes).
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.