Skip to content

Instantly share code, notes, and snippets.

@jbourassa
Created September 11, 2013 20:32
Show Gist options
  • Save jbourassa/6529382 to your computer and use it in GitHub Desktop.
Save jbourassa/6529382 to your computer and use it in GitHub Desktop.
`window.onbeforeunload` with TurboLinks support.
@inspire22
Copy link

This looks nice. So to use it, you'd start with

Unloader.register -> if true then "Are you sure?"

Doesn't IE8 need some special handling, with setting e.returnValue? http://stackoverflow.com/questions/1119289/how-to-show-the-are-you-sure-you-want-to-navigate-away-from-this-page-when-ch

@allenwyma
Copy link

Hmm, wasn't able to get this to work

$('form[data-check-form]').each ->
      $this = $(this)
      form_clean = $this.serialize()
      Unloader.register -> "Not clean" if $this.serialize() != form_clean

Am I doing something wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment