before-change event is not trigged when I click "go back" button

507 views Asked by At

environment:
rails4.01 + turbolinks2.0 + jquery

browser:
Chrome, Safari 7.0

goal:
when user changed content in form page and leave (not saved), I will prompt them.

my solution

$ ->
  $(document).on 'page:before-change', ->
    confirm 'Are you sure you want to leave this page?'

problem:
when I click other links in browser page, it works well. if I click 'go back' button belongs to browser, page:before-change is not triggered, how to fix issue in this case.

0

There are 0 answers