Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Rails with Hotwire/Turbo doing get requests on link hover

Using rails (7.1.3.2) and turbo-rails (2.0.4). For some reason, when ever I hover over any link in my app, a GET request is happening to the linked page. I check my inspector and there is a mouseenter event coming from turbo.es2017-esm.js:3135.

When I disable it, the GET requests don’t happen.

Here is an example of a link I have

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<%= link_to "Edit", edit_post_path(@post), class: "hover:text-black flex-none", data: { turbo_frame: :resource_frame } %>

Anyone know why this is happening and how I can stop it?

>Solution :

It’s a new instaclick behavior in Turbo v8:
https://github.com/hotwired/turbo/pull/1101

You can disable it by adding a meta tag to your page:

<meta name="turbo-prefetch" content="false">

or data attribute to/around your links:

<a href="/" data-turbo-prefetch="false">Home</a>

<div data-turbo-prefetch="false">
  <a href="/">Home</a>
  ...
</div>

https://turbo.hotwired.dev/handbook/drive#instantclick

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading