Making Select2 work with Turbolinks


Hi everyone,

If you are trying to implement Select2 into an app (Rails, Laravel) that uses Turbolinks to make page transitions fast, but you’re finding that Select2 is unresponsive when you do a back operation, here’s a video.

It explains the problem (how turbolinks works and what causes the problem) and which offers a solution to fix it. It involves Stimulus, an elegant way to load/unload components like Select2 on a page and get them ready for turbolinks’ snapshot cache of back pages.