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 is not defined with Rails 5.1 and Yarn #924

Open
davidmccoy opened this issue May 1, 2017 · 3 comments
Open

jQuery is not defined with Rails 5.1 and Yarn #924

davidmccoy opened this issue May 1, 2017 · 3 comments

Comments

@davidmccoy
Copy link

Hello! It seems like this gem isn't cooperating with Rails' move towards Wepback/Yarn and the fact that Rails 5.1 no longer includes jQuery by default.

Adding jQuery through Yarn with yarn add jquery results in the following error in the console:

Uncaught ReferenceError: jQuery is not defined

The only way to resolve this is to avoid packing jQuery with Yarn and manually including it in the pre-Rails 5.1 way. I had to add gem 'jquery-rails' back to my Gemfile and then require jquery/jquery_ujs in my app/assets/javascripts/application.js file. (//= require jquery //= require jquery_ujs)

@tothestar
Copy link

+1

@tothestar
Copy link

@davidmccoy even use jquery-rails not work.
i always got this error:
bootstrap.self-fdc98de….js?body=1:3 Uncaught TypeError: $(...).popover is not a function at HTMLDocument.<anonymous> (bootstrap.self-fdc98de….js?body=1:3) at fire (jquery.self-bd7ddd3….js?body=1:3233) at Object.fireWith [as resolveWith] (jquery.self-bd7ddd3….js?body=1:3363) at Function.ready (jquery.self-bd7ddd3….js?body=1:3583) at HTMLDocument.completed (jquery.self-bd7ddd3….js?body=1:3618)

@Latori
Copy link

Latori commented Jun 19, 2017

@tothestar you have to manually require twitter/bootstrap to fix jquery errors (after adding gem jquery-rails) in assets/javascript/application.js

//= require twitter/bootstrap

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