'Rails 6 easy-autocomplete simply not working

On Rails 6, using webpack, I'm trying to get easy-autocomplete working, as per https://joelc.io/dynamic-autocomplete-rails-6.

I have the package installed (through yarn add) in node_modules/easy-autocomplete, but can't seem to get it to work. I've added require("easy-autocomplete") to my application.js pack, and @import "easy-autocomplete/dist/easy-autocomplete"; to application.css.scss. I've checked that jQuery itself works.

In my partial, _search_box.html.slim:

= simple_form_for 'address', url: {controller: :community, action: :map}, method: :get do |f|
    = f.input_field :q, placeholder: "Search address...", class: "form-control search-addresses", autocomplete: "off", data: {behavior: "autocomplete"}

Which renders as:

<form novalidate="novalidate" class="simple_form address" action="/" accept-charset="UTF-8" method="get">
    <input class="string required form-control search-addresses" autocomplete="off" data-behavior="autocomplete" placeholder="Search address..." type="text" name="address[q]" id="address_q" />
</form>

But now I'm trying to test it in the console, as per the page linked above.

> var options = {data: ["1400 CENTRAL AVE", "1506 IOWA ST"]};
< undefined
> $('*[data-behavior="autocomplete"]').easyAutocomplete(options);
VM78:1 Uncaught TypeError: $(...).easyAutocomplete is not a function
    at <anonymous>:1:38

I don't know why I'm getting this error. I have very little information to go on, no "failed to load" messages or anything.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source