Skip to content

Instantly share code, notes, and snippets.

@maccman
Created July 31, 2013 19:17
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maccman/6125215 to your computer and use it in GitHub Desktop.
Save maccman/6125215 to your computer and use it in GitHub Desktop.
$ = 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