Rails 3.2 Ajax Update Div when Text Field Populated
- by ctilley79
In the end I would like a text field that passes a client_id to the partial. I would like to do this asynchronously so the shipment_products partial would dynamically change when the textfield value was updated. What is the best way to do this?
In index.html.erb
<!-- Text Field Here-->
<div id="available_products">
<%= render "shipment_products" %>
</div>
In _shipment_products.html.erb
<div id="shipment_products_container">
<h3>Assign Products to Ship<\h3>
<ul class="shipment_products" id="shipment_products">
<% Product.by_client(client_id).each do |product|%> <!-- TextField value passed here -->
<%= content_tag_for :li, product, :value => product.id do %>
<%= hidden_field_tag("shipment[product_ids][]", product.id) %>
<%= product.product_name %>
<% end %>
<% end %>
<\ul>
</div>
This is similar to what I want in the end.