x
1
2
3
4
5
6
7
8
<!-- Back -->
<a class="font-medium underline" data-controller="navigation" data-action="navigation#back:prevent" href="#">Go back one page</a>
<!-- Forward -->
<a class="font-medium underline" data-controller="navigation" data-action="navigation#forward:prevent" href="#">Go foward one page</a>
<!-- Reload -->
<a class="font-medium underline" data-controller="navigation" data-action="navigation#reload:prevent" href="#">Reload current page</a>
1
2
3
4
5
6
7
8
<%# Back %>
<%= link_to "Go back one page", "#", class: "font-medium underline", data: { controller: "navigation", action: "navigation#back:prevent" } %>
<%# Forward %>
<%= link_to "Go foward one page", "#", class: "font-medium underline", data: { controller: "navigation", action: "navigation#forward:prevent" } %>
<%# Reload %>
<%= link_to "Reload current page", "#", class: "font-medium underline", data: { controller: "navigation", action: "navigation#reload:prevent" } %>
CSS is not required or multiple files are needed, check the notes.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { Controller } from "@hotwired/stimulus"
import { Turbo } from "@hotwired/turbo-rails"
export default class extends Controller {
back() {
history.back()
}
forward() {
history.forward()
}
reload() {
Turbo.visit(location.href, { action: "replace", shouldCacheSnapshot: false })
}
}