Access4all / EPUB

3 stars 1 forks source link

Missing mechanism to prevent accidentally navigating away from editor #65

Open jmuheim opened 9 years ago

jmuheim commented 9 years ago

When I accidentally navigate away from the editor, there's no mechanism which asks me whether I want to really leave the page and lose my edits.

I tried to drag&drop an image from my desktop to the editor, but because I didn't point exactly, the browser thought I wanted to open the image, and navigated away from the editor. After pressing the back-button, my edits were lost.

qtnc commented 9 years ago

This problem has been partially solved with the "do you want to save" dialog box, which appears when you click on a link in the editor application.

For the rest such as the case you are mentionning, there is onunload event, but at the time the event is sent, it don't allow such a dialog box to appear and there is no way to prevent from navigating away. I also tried to send an AJAX request to save the current document without asking anything to the user when this event is fired, but it isn't always desirable (what if I really want to go away without saving ?, and it doesn't reliably work anyway:

  1. If the new page is faster to load than the AJAX request, then the AJAX request is cancelled before it arrives and thus nothing is saved.
  2. There is the synchrone mode to solve the problem above, i.e. the browser waits for the AJAX request to complete before navigating away. But in this case, sometimes the browser hangs if the AJAX request takes too long to complete. This is notably the case with IE.

If you have another suggestion, I would be happy to hear it.

jmuheim commented 9 years ago

It seems there are a lot of suggestions about this:

https://www.google.ch/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=prevent%20navigating%20away%20from%20page