6

I have an long operation on the page. How can I said user wait a bit when he make the navigation change?

The idea is to show the promt dialog. But the trouble prevent default Aurelia router behavior.

How make it works in Aurelia.js?

Egor Malkevich
  • 1,516
  • 1
  • 11
  • 24
  • 1
    Take a look to this previous asked querstion: http://stackoverflow.com/questions/1704533/intercept-page-exit-event – dlopez May 12 '16 at 10:27

1 Answers1

16

You could use the canDeactivate hook of your view-model. Like this:

canDeactivate() {
   return confirm('Are you sure you want to leave this page?');
}

canDeactivate() - Implement this hook if you want to control whether or not the router can navigate away from your view-model when moving to a new route. Return a boolean value, a promise for a boolean value, or a navigation command.

More information at http://aurelia.io/docs.html#/aurelia/framework/1.0.0-beta.1.2.2/doc/article/cheat-sheet/7

Fabio
  • 11,892
  • 1
  • 25
  • 41