我想在get_autocomplete_items(parameters)
我试过
= rec.autocomplete_field :name, autocomplete_recruiter_name_job_applications_path, :placeholder=>"Recruiter name",:id_element=>"#phone", :param_name => 'search'
但是ajax请求是通过相同的参数发送而不是添加我的其他参数
GET http://localhost:3000/job_applications/autocomplete_recruiter_name?term=test
我想要这样的网址
GET http://localhost:3000/job_applications/autocomplete_recruiter_name?term=test&search=series
以便我可以访问
中的隐藏字段值def get_autocomplete_items(parameters)
答案 0 :(得分:1)
我已经解决了这个问题。
= rec.hidden_field :recruitment_co_id
= rec.autocomplete_field :name, autocomplete_recruiter_name_job_applications_path(:recruitment_co_id=>''), :placeholder=>"Recruiter name",:id_element=>"#phone"
$(document).ready(function(){
$("#recruiter_recruitment_co_id").val($("#recruiter_name").attr("data-autocomplete"))
$('#recruiter_name').bind('autocompleteselect', function(event, ui) {
$("#recruiter_phone").val(ui.item.phone)
$("#recruiter_email").val(ui.item.email)
});
$("#recruitment_co_name").bind('autocompleteselect', function(event, ui) {
data_auto = $("#recruiter_recruitment_co_id").val() + ui.item.id
$("#recruiter_name").attr("data-autocomplete",data_auto)
});
});