Hi
I’m trying to create an Ajax request that displays a list of inventory
items resulting from a search on a keyword. How can I insert the list
of inventory items using a partial or a string of html onto the page
following the ajax request? The following doesn’t work because I
can’t use a content_tag helper method in a controller.
I guess another question would be why doesn’t the inventories div
update and show the inventory items after the ajax request?
I have this in my controller (this uses a string of html)
def find_by_keyword
@inventories = Inventory.find(:all, :conditions => [‘inventory_id
LIKE ?’, params[:inventory][:keyword]])
@inventories_list = @inventories.map { |inventory|
content_tag(“li”, inventory[‘id’])}
render :inline => @inventories_list
end
And this in the view:
<% form_remote_tag :url => { :controller =>
“purchase_orders”, :action => “find_by_keyword” }, :update=>
“inventories” do |f| -%>
<%= model_auto_completer(‘inventory[keyword]’, ‘’,
‘inventory[inventory_id]’, ‘’, {:method => :get})%>
<%= submit_tag “Find!” %>
<% end %>