Cancelling visits before they begin

suggest change

Turbolinks provides an event listener that can be used to stop visits from occurring. Listen to the turbolinks:before-visit event to be notified when a visit is about to commence.

In the event handler, you can use:

// pure javascript
event.data.url

or

// jQuery
$event.originalEvent.data.url

to retrieve the location of the visit. The visit can then be cancelled by calling:

event.preventDefault()

NOTE:

According to the official turbolinks docs:

Restoration visits cannot be canceled and do not fire turbolinks:before-visit.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Turbolinks:
*Cancelling visits before they begin

Table Of Contents
55CSV
62Turbolinks