There is a progress bar when Turbolinks.visit is called.
I want to show and hide it manually (because some of my xhr request are a bit long), is it possible?
(In Turbolinks 3, there was Turbolinks.ProgressBar.start(); but it was not a public api and not working anymore)
Turbolinks 5 has the ProgressBar instance deeper in the singleton controller object. The following should work:
function safeStartTurbolinksProgress() {
if(!Turbolinks.supported) { return; }
Turbolinks.controller.adapter.progressBar.setValue(0);
Turbolinks.controller.adapter.progressBar.show();
}
function safeStopTurbolinksProgress() {
if(!Turbolinks.supported) { return; }
Turbolinks.controller.adapter.progressBar.hide();
Turbolinks.controller.adapter.progressBar.setValue(100);
}
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