jquery-rails icon indicating copy to clipboard operation
jquery-rails copied to clipboard

jquery-rails doesn't work correctly in Rails 7

Open infernaLwizarD opened this issue 2 years ago • 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 avatar Dec 04 '22 17:12 infernaLwizarD

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

Hope this helps

eclectic-coding avatar Dec 16 '22 13:12 eclectic-coding

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.

9211ali avatar Aug 25 '23 11:08 9211ali