I am experimenting with configuring turbo links correctly. Is there any way (by tracing, javascript console, examining the html, or anything) to see proof that turbo links is working? Simply looking for "faster" or "no flashing" is too subjective.
on('turbolinks:load', function (){ alert("turbolinks on load event works") }); If you reload a page where this JS is running, and the page shows you an alert, turbolinks is working.
Turbolinks works by automatically fetching your page, swapping its DOM's body, and mixing it with the head . This allows the library to understand what has changed on the page without having to infer a full load.
6.1 How Turbolinks Works The only thing you have to do to enable Turbolinks is have it in your Gemfile, and put //= require turbolinks in your JavaScript manifest, which is usually app/assets/javascripts/application.
Turbolinks saves a copy of the current page to its cache just before rendering a new page. Note that Turbolinks copies the page using cloneNode(true) , which means any attached event listeners and associated data are discarded.
Try this in the application.js file (or any other js/coffee file that's getting run):
$(document).on('turbolinks:load', function (){ alert("turbolinks on load event works") });
If you reload a page where this JS is running, and the page shows you an alert, turbolinks is working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With