I'm trying to integrate jQuery UI Autocomplete in my Rails 4.0 application like described in this Railscast: 102-AutoCompleteAssociationRevised.
Unfortunately, the autocompletion doesn't work. I don't get any suggestions although the rendered HTML looks fine:
<input id="plan_part_name" type="text" name="plan[part_name]" data-autocomplete-source="["foo","food","foobar"]"></input>
I also deactivated Turbolinks, but nothing changed...
In my Gemfile I included gem 'jquery-ui-rails'
and my application.js looks like this:
//= require jquery
//= require jquery.ui.all
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require jquery-fileupload/basic
//= require jquery-fileupload/vendor/tmpl
//= require_tree .
This is the form, that I'm using, edit.html.erb:
<%= form_for [@project, @plan], remote: true, html: { id: "edit-form-#{@plan.id}" } do |f| %>
<%= f.text_field :title %>
<%= f.text_field :part_name, data: {autocomplete_source: %w[ foo food foobar ]} %>
<%= f.submit "Update" %>
<% end %>
autocomplete.js.coffee:
autocomplete = ->
$('#plan_part_name').autocomplete
source: $('#plan_part_name').data('autocomplete-source')
$(document).ready(autocomplete)
$(document).on('page:load', autocomplete)