I am trying to implement auto complete feature in my rails application.I am able to get print the array that i passed for the autocomplete.but the auto complete is not working.
My controller code:
def new
@release = Release.new
@names = User.all(:select => "name").map { |x| x.name }
respond_to do |format|
format.html # new.html.erb
end
end
My view code:
%td.grid.full_panels
-table_panel "Assign Testers" do
%table
%th Name
= form.label :tester_tokens, "Testers"
= form.text_field :tester_tokens
:javascript
var data="#{escape_javascript @names.to_json}";
= javascript_include_tag :defaults,:cache => true
My application.js code:
$(document).ready(function() {
alert (data);
$('#release_tester_tokens').autocomplete(data);
});
The autocomplete plugin actually expects an object literal with options when initialized.
To set the data, use the source property: