I have a new Rails 7 application. I'm currently trying to learn all the new features since Rails 5. I want to use the following code in my javascript file, but so far I'm getting the following error: Uncaught ReferenceError: $ is not defined
.
$(document).on("turbo:load", () => {
console.log("turbo!");
});
Here are two other relevant files. If I need to post anything else please let me know.
importmap.rb
pin "application", preload: true
pin "jquery", to: "https://ga.jspm.io/npm:jquery@3.6.0/dist/jquery.js", preload: true
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
pin "el-transition", to: "https://ga.jspm.io/npm:el-transition@0.0.7/index.js"
pin_all_from "app/javascript/controllers", under: "controllers"
application.js
import "@hotwired/turbo-rails"
import "jquery"
$(document).on("turbo:load", () => {
console.log("turbo!");
});