Turbolinks and EventListeners in coffeescript!

Created: 2020-01-21, Last Updated: 2023-02-04

This is an older post. Most likely it is out of date.

Turbolinks was giving me a hassle when I was trying to figure out how to add triggers to certain JavaScript events in a project I was working on. Eventually, I gave up and tried to disable Turbolinks. It turned out I didn't do it right and things were not working right. This became apparent when you tried to submit a form. The page would not redirect to the success page.

That's when I found out I didn't disable Turbolinks properly. I was being greeted with a Turbolinks not defined message, and instead of digging in my heels I decided to give Turbolinks another go.

What I found out is that I'm on Turbolinks 5.2 and that I need to be looking that the turbolinks:load instead of 'ready page:load'.