Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jquery-rails doesn't work correctly in Rails 7 #291

Open
infernaLwizarD opened this issue Dec 4, 2022 · 2 comments
Open

jquery-rails doesn't work correctly in Rails 7 #291

infernaLwizarD opened this issue Dec 4, 2022 · 2 comments

Comments

@infernaLwizarD
Copy link

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.

@eclectic-coding
Copy link

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

Hope this helps

kidhab added a commit to foodcoops/sharedlists that referenced this issue Feb 22, 2023
kidhab added a commit to foodcoops/sharedlists that referenced this issue Feb 22, 2023
kidhab added a commit to foodcoops/sharedlists that referenced this issue Feb 22, 2023
kidhab added a commit to foodcoops/sharedlists that referenced this issue Feb 22, 2023
kidhab added a commit to foodcoops/sharedlists that referenced this issue Feb 22, 2023
* Switch to importmap and get rid of webpack

* Load jquery without importmap.
Fixes rails/jquery-rails#291
@9211ali
Copy link

9211ali commented Aug 25, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants