0
votes

I am interested in showing a modal on refreshing a certain route in an ember app. The modal will have an 'ok' action that will continue the route refresh and a 'cancel' action that will abort the refresh.

I know ember has the 'refresh()' method which can be called from somewhere within the route but cannot act as an event. And, the 'willTransition' event only gets activated if the url path changes. There is also the 'activate()' event which only gets triggered upon entering the route.

Is there a way to handle a route refresh event and also abort or continue the refresh based on a user action?

1

1 Answers

0
votes

You can use the beforeModel hook. Here you can save your transition, transition to another route (to show the message), and then .retry() your original transition.

This is basically how authentication works. A good example is ember-simple-auth.

I'm not 100% sure what exactly you wanna do, a message to show before leaving a route, or a message before entering a route, but beforeModel is probably worth a look!