I'm starting a new project in rails 6 and it's going to be my first experience with Webpack, I'm having problems using the popover, tooltip, dropdown.
application.js:37 Uncaught TypeError: $(...).dropdown is not a function
environment.js
const { environment } = require('@rails/webpacker')
const webpack = require('webpack')
environment.plugins.append('Provide',
new webpack.ProvidePlugin({
$: 'jquery/src/jquery',
jQuery: 'jquery/src/jquery',
jquery: 'jquery',
'window.jQuery': 'jquery',
Popper: ['popper.js', 'default'],
Rails: ['@rails/ujs']
})
)
module.exports = environment
application.js
import 'core-js/stable'
import 'regenerator-runtime/runtime'
require("@rails/ujs").start()
require("turbolinks").start()
require("channels")
import 'bootstrap'
import './menu-left.cleanui-custom'
import './menu-right.cleanui-custom'
// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
import '../stylesheets/application'
document.addEventListener("turbolinks:load", () => {
$('[data-toggle=popover-hover]').popover({
trigger: 'hover',
animation: false
});
$("[data-toggle=tooltip]").tooltip({
trigger: 'hover',
animation: false
});
});
$('.dropdown-toggle').dropdown();
Where can the mistake come from? The truth is I'm still pretty lost with webpack.