You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Turbo Drive triggers a series of events during navigation. The most significant of these is the turbo:load event, 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_toproducts_pathdo%>
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.jsconsole.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:
Maybe I'm doing something fundamentally wrong, but the following scenario is not working as expected.
🎈 Expected
According to the Turbo docs:
🎈 Actual
Given some views:
and the according JS
we get the following behavior, i.e. the first page visit does not trigger a
turbo:loadwhen clicking on a link:rails-turbo.mp4
When directly vising the
/productspage without clicking on a link, theturbo:loadevent 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