Created
October 4, 2013 14:40
-
-
Save takuyan/6827059 to your computer and use it in GitHub Desktop.
for beforeunload event of turbolinks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#= require jquery | |
#= require jquery.turbolinks | |
#= require turbolinks | |
#= require_self | |
returnAlert = -> | |
$(document).on 'page:before-change', -> | |
url = document.location.href | |
if url.match('(new|edit)$') | |
confirm 'Are you sure?' | |
else | |
$(document).off 'page:before-change' | |
$(document).ready returnAlert |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment