Closed johnpitchko closed 5 months ago
I also can't get jquery to load. Can't find any explanation on the internet about why.
Same issue here.
If you are using webpacker (gem 'webpacker'), then to have to map the $ an jquery instructions to the compiling:
var webpack = require('webpack');
const { environment } = require('@rails/webpacker')
environment.plugins.prepend('Provide',
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
Popper: ['popper.js', 'default']
}));
module.exports = environment
Followed the instructions provided.
Added
gem 'jquery-rails' to my Gemfile. Did bundle update and confirmed that I saw
Using jquery-rails 4.4.0` in the output.Added the following to
app/assets/javascripts/application.js
:To test that jQuery works, I added the following to one of my index.erb files:
When I restart rails and refresh the page, I receive the Doesn't work alert.
However, if I add the usual jQuery script tag to the page:
I receive the Yeah! alert.
Am I missing something here? TIA