Ajax request

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 %>

<% if [email protected]?%> <% for inventory in @inventories %> <% link_to inventory['id'], :controller => "purchase_orders", :action => "new", :inventory_id => inventory['id'] %> <% end %> <% end %>

On 10 May 2011, at 23:48, Mlle [email protected] wrote:

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.

You can have a view file for that action as you would for any other
action

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs