Skip to content

Instantly share code, notes, and snippets.

@shohey1226
Last active June 2, 2022 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shohey1226/6018e5b35695a25620186d19d1a44b77 to your computer and use it in GitHub Desktop.
Save shohey1226/6018e5b35695a25620186d19d1a44b77 to your computer and use it in GitHub Desktop.
How to load Jquery with Turbo

Googling Turbo is hard. Always google hits turbolinks. It needs to use -turbolink all the time. And less document comparing to turbolinks.

There is an event similar to turbolink to load JS.

import "@hotwired/turbo-rails"; 
import "controllers";
import jquery from "jquery";

window.$ = jquery;

$(document).on('turbo:load', function() {
  console.log("Hello Rails7!");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment