Created
July 31, 2013 19:17
-
-
Save maccman/6125215 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
$ = jQuery | |
$.activeTransforms = 0 | |
$(document).ajaxSend (e, xhr, settings) -> | |
return unless settings.warn | |
$.activeTransforms += 1 | |
$(document).ajaxComplete (e, xhr, settings) -> | |
return unless settings.warn | |
$.activeTransforms -= 1 | |
window.onbeforeunload or= -> | |
if $.activeTransforms | |
'''There are some pending network requests which | |
means closing the page may lose unsaved data.''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment