Created
September 5, 2009 18:24
-
-
Save ltackett/181473 to your computer and use it in GitHub Desktop.
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
var needToConfirm = false; | |
$('#experience textarea#experience_body, #new-discussion textarea#discussion_posts_attributes_0_text').bind('keypress', function(){ | |
$('body').css('background-color', '#f00') | |
var needToConfirm = true; | |
}); | |
$('input[type="submit"]').bind('click', function(){ | |
$('body').css('background-color', '#fff') | |
var needToConfirm = false; | |
}); | |
window.onbeforeunload = confirmExit; | |
function confirmExit(){ | |
if (needToConfirm == true){ | |
return "You haven't submitted your changes, and it looks \n" + | |
"like you're trying to browse away from this page. \n" + | |
"If you leave this page, your current changes will be lost."; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment