我在rails应用程序中使用jquery.autocomplete.js。一切都很好。
在尝试执行编辑操作时,将从数据库中获取值并填充文本框。在尝试编辑此文本框时,自动完成功能无效。即,如果数据库中已有2个名称,并且使用逗号输入,如果我尝试输入athirdname,则不会自动填写名称
我的.js文件:
$(function() {
alert("inside");
var string1 = " ";
string1 = names.toString();
var arrayOfStrings = new Array();
arrayOfStrings = string1.split(",");
$("#release_tester_tokens").autocomplete(arrayOfStrings,{
multipleSeparator: ", ",
multiple: true,
});
});
我的观点文件:
%td=form.text_area :tester_tokens ,:value=>@tester_tokens,:cols=>100,:rows=>4
我的控制器:
def edit
@release = Release.find(params[:id])
tester_ids = (@release.tester_ids) ? (@release.tester_ids) : []
@tester_tokens = ""
tester_ids.each do |tester_id|
tester_name = User.find(tester_id)
@tester_tokens = @tester_tokens + tester_name.name + ","
end
@ic_ids = []
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @release }
end
end