On 10 May 2011, at 23:48, Mlle
<emstolfo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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>
> 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 %>
>
> <div id = "inventories">
> <% if !@inventories.nil?%>
> <% for inventory in @inventories %>
> <% link_to inventory[''id''], :controller
=>
> "purchase_orders", :action => "new", :inventory_id
=> inventory[''id'']
> %>
> <% end %>
> <% end %>
> </div>
>
> --
> 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.
>
--
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.