Skip to main content

How do I use easyautocomplete in rails 6?

Rails • Asked by Christopher

I tried adding it with yarn and through rails assets but nothings seems to work.

Bit low on info to really help you here. Any errors (from console) you can share? What is your current set up?

I added it with yarn add easy-automplete
my application.js

// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.


window.Rails = Rails

import 'bootstrap'
import 'easy-autocomplete/dist/jquery.easy-autocomplete'
import "controllers"


my application.scss

//= require actiontext

@import 'bootstrap';
@import 'easy-autocomplete/dist/easy-autocomplete';
@import 'easy-autocomplete/dist/easy-autocomplete.themes';

My first guess is you haven't added jquery: yarn add jquery. Are you also sure these @imports are correct?
I'm sure the console from in your dev tools would give you another clue.

I just get this error

Uncaught TypeError: $(...).easyAutocomplete is not a function at <anonymous>:1:12

Looks like jQuery is indeed missing. 🙂

thank you I think I got it now

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.