我有以下型号:Ruby on Rails的 - jQuery的使用AJAX
create_table "mouldings", :force => true do |t|
t.string "suppliers_code"
t.datetime "created_at"
t.datetime "updated_at"
t.string "name"
t.integer "supplier_id"
t.decimal "length", :precision => 3, :scale => 2
t.decimal "cost", :precision => 4, :scale => 2
t.integer "width"
t.integer "depth"
end
当用户在窗体上选择造型我想通过Ajax获得的成型的成本,并用它来得到一个使用JavaScript生成报价。下面是从表单中选择标签:
<select id="order_item_moulding_1_id" name="order_item_moulding_1[id]">
<option value="">Select a moulding 1</option>
<option value="1">123 589 698</option>
<option value="2">897 896 887</option>
<option value="3">876 234 567</option>
</select>
这里是JavaScript文件的一部分:
$(document).ready(function() {
$('#order_item_moulding_1_id').change(function() {
var moulding_1_price = ;
});
});
如何使用Ajax来设置变量moulding_1_price?
谢谢,我使用`collection_select`来生成选择标记。设置'data-price`属性的正确方法是什么? `html_options = {'data-price'=> ??? }` – freshest 2010-11-29 16:17:17