I'm trying to introduce the jQuery UI autocomplete feature to a widget in a Rails 3.1.3 app. It doesn't do anything and on inspecting the scripts in Chrome developer tools, I see the following:
jQuery(function() {
return $("#location").autocomplete({
locations.js:3 Uncaught TypeError: Object #<Object> has no method 'autocomplete'
source: ["foo", "food", "four"]
});
});
I've included jQuery UI in application.js:
//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require_tree .
My coffeescript has the following:
jQuery ->
$('#location').autocomplete
source: ["foo", "food", "four"]
What am I missing!?
It turns out that since I also had active_admin, "//=require_tree ." was adding an older version of jQuery from the active_admin/vendor path which was removing the autocomplete method. Got rid of the "//=require_tree ." for now and explicitly added "//=require locations" and it works just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With