0

I use rails 7 with importmap. On view I added

<% content_for :head do %>
  <%= javascript_include_tag 'path/to/script', 'data-turbo-track': 'reload' %>
<% end %>

for run script only on it. After that the page is always loaded twice when you go to it (the script is run once), and any other page loaded twice once after leaving the page with the script (in this case, the script run again once). If remove 'data-turbo-track': 'reload' - script not running at first time, but he is run every time after in any page, but without page double load, i.e. it is loaded when you go to the page and continues to hang until the any page is reloaded (F5). What's happening?

P.S. Script file:

$(document).on("turbo:load", () => {
    alert("test")
});
infernal
  • 23
  • 4

0 Answers0