我是RoR的新手,我有两个模型CustomerDetail和Invoice.Im动态填充customer_name,它是从customer_detail创建的。我必须根据customer_name显示customer_id,地址。
JS
这是我的Jquery文件
$("#customer_name").prepend('<option selected="" value="Add New">Add New</option>');
$("#customer_name").prepend("<option value='Add New'></option>").val('aaaaaaaaaa');
$("#customer_name").on('change', function() {
alert($('#customer_name').val());
if ($('#customer_name').val() == 'Add New'){
window.location.href = "/customer_details/new";
}
$('#cust_id').val($(this).find("option:selected").attr("value"));
});
<button type="button" class="btn dropdown-toggle form-control selectpicker btn-default" data-toggle="dropdown" data-id="customer_name" title="nnnnnnnn"><span class="filter-option pull-left">nnnnnnnn</span> <span class="caret"></span></button>
<input autofocus="autofocus" class="form-control" id="cust_id" type="text" name="invoice[customer_id]">