Javascript Alert For Unsaved Changes with Turbolinks, Jquery, And Rails 4
- Categories:
- ruby
- rails
- javascript
Update 2020-04-04: This script based on old version Coffescript, jQuery, and Turbolinks circa 2013.
jQuery change event can be used to detect form change. But because Turbolinks pages will change without full reload, we can’t rely on DOMContentLoaded
or jQuery.ready()
to trigger change event. Here is how to write jQuery change event code with Turbolinks enabled. Tested with Rails 4.0.0. Github Gist.
- Tags:
- #ruby
- #rails
- #ruby on rails
- #javascript
Sponsored Links
- Register to Digital Ocean cloud with this link and get $200 credit
- Looking for cheap CDN? Bunny is the answer
- Alternative Cloud besides AWS and Digital Ocean