2
我有一個購物車應用程序,您可以從目錄中選擇產品。我想根據選擇動態填充幾列,如可用顏色,全部通過ajax。動態選擇與導軌和jQuery
這是我的看法,當你添加新項目
<td><%= f.collection_select(:product_id, Product.active.all, :id, :name, :prompt => 'Select Product') %></td>
<td><%= f.text_field :quantity, :size => 6 %></td>
<td><%= f.collection_select(:color_id, Color.all, :id, :name, :prompt => 'Select Color') %></td>
<td><%= f.text_field :price, :size => 8 %></td>
<td><%= f.link_to_remove "remove" %></td>
我想根據的product_id值來設定價格和顏色選擇。這是我到目前爲止:
$('select#order_items_new').change(function() {
// How to retrieve table columns based on product_id value?
});