Ruby on Rails - ruby on rails forumcancelling visits before they begin in ruby on rails - ruby on rails tutorial - rails guides - rails tutorial - ruby rails
- 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.
Event handler, We can use:
// pure javascript
event.data.url
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
or
// jQuery
$event.originalEvent.data.url
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
The visit can then be cancelled by calling given below code:
event.preventDefault()