rails/jquery-rails

jquery-rails doesn't work correctly in Rails 7

infernaLwizarD opened this issue · 2 comments

Hello, I started to use Rails 7 with importmap and faced the following problem: jquery-rails doesn't work correctly. When I try to use jquery on the page, an error appears:
Uncaught ReferenceError: $ is not defined
Because of this, I had to remove the gem and added files manually to vendor/javascript folder. Then in application.html.erb I added jquery.min like this:

  <%= javascript_include_tag 'jquery-3.6.0.min', 'data-turbo-track': 'reload' %>
  <%= javascript_importmap_tags %>

And after that the error was gone, but I would like to use the gem again.

@infernaLwizarD I just read this morning a really good response on StackOverflow on setting up jQuery on Rails 7 using importmaps.

Hope this helps

Hi @eclectic-coding @infernaLwizarD, I am working on a rails upgrade to 7.0.7 but jQuery is not working now. How to fix that.