Skip to Content
1
Former Member
May 26, 2016 at 10:12 AM

Save changes message before navigation

1225 Views

As part of our application we would like to notify users when they're attempting to leave a page if there are unsaved changes present. This is easily done for the page's navButton, however we're struggling with a similar implementation for the browser's back button.

By attaching our controller to the HashChanger hashChanged event we can detect the change, however we can't find a way to prevent the navigation from taking place. Neither the event's cancelBubble nor preventDefault methods prevent the change from happening. We've also tried calling stop on the router, but unfortunately to no effect.

Seeing as the Fiori guidelines suggest always implementing such a confirmation dialog I had expected this to be a trivial task. Can someone shed some light on how to reliably implement such a feature? Have we perhaps overlooked something in UI5 that can be used for this?