jquery doesn't work in js.erb file
Hey I'm working on an rails 6 application and try to render an partial in an js.erb file but get this error in the chrome console:
Uncaught TypeError: Cannot read property 'append' of null
Is there something new with js.erb files in rails 6 or am I missing something?
Hello! I'm trying to also get jQuery to work in a create.js.erb
file. Would I still need to add the code snippet you provided above if I have this in my environment.js
:
const { environment } = require('@rails/webpacker')
const webpack = require("webpack")
environment.plugins.append("Provide", new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
Popper: ['popper.js', 'default'],
}))
module.exports = environment
or should I include it anyway? Thanks!