-
Notifications
You must be signed in to change notification settings - Fork 365
Open
Description
Maybe I'm doing something fundamentally wrong, but the following scenario is not working as expected.
🎈 Expected
According to the Turbo docs:
Turbo Drive triggers a series of events during navigation. The most significant of these is the
turbo:loadevent, which fires once on the initial page load, and again after every Turbo Drive visit.
🎈 Actual
Given some views:
<%# app/views/playground.html.erb %>
Hello to the playground
<div>
<%= link_to products_path do %>
Go to products
<% end %>
</div><%# app/views/products/index.html.erb %>
<%= javascript_include_tag "product.js" %>
<h1>Products#index</h1>
<p>Find me in app/views/products/index.html.erb</p>and the according JS
// app/javascript/product.js
console.log("Hello from product.js");
document.addEventListener("turbo:load", function () {
console.log("turbo:load triggered in product.js");
});we get the following behavior, i.e. the first page visit does not trigger a turbo:load when clicking on a link:
rails-turbo.mp4
When directly vising the /products page without clicking on a link, the turbo:load event triggers on the initial page load as expected:
rails-turbo-direct-visit.mp4
🎈 Reproduction
See https://github.com/Splines/rails-turbo-repro for a reproduction.
🎈 Versions
- Rails version: 8.1.2
- Rack version: 3.2.5
- Ruby version: ruby 3.4.7 (2025-10-08 revision 7a5688e2a2) +YJIT +PRISM [x86_64-linux]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels