Search code examples
rubyruby-on-rails-5turbolinksturbolinks-5

Turbolinks, On destroy event - Ruby on rails 5


I would like to know if there is an event that is called when a page is destroyed/changed. For example i'm in localhost:3000 and i would like to navigate to localhost:3000/articles but before that i need to destroy some javascripts components, so i was wondering if there is a way to have something like

$(document).on('turbolinks:before-destroy', function() {});

Or something like that.


Solution

  • This was solved. I found the list of events for turbolinks: github.com/turbolinks/turbolinks#full-list-of-events. The one i was looking for is turbolinks:before-visit