Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

waltergrimmvie's avatar

Jquery and other plugins don't work in Laravel Turbolinks

I added turbolinks in existing my laravel application. It worked well without reloading page. But jQuery and other plugin init functions didn't work. I added data-turbolinks-track="true" to every js and css link includes

when I did

$("test_btn").click(function() {
   console.log("test");
   $("#my_modal").modal("toggle");
});

console.log worked well, but for modal function, it displays error.

$(...).modal is not a function

Can anyone help me?

0 likes
1 reply
joshhanley's avatar

It's probably because the modal plugin is initialised using $(document).ready(...); which doesn't happen with Turbolinks.

I found a blog post here https://www.honeybadger.io/blog/turbolinks/ about how they handled migrating a site with jQuery to using Turbolinks.

Have a look and let me know if you have any issues.

Please or to participate in this conversation.