I have upgraded my application from Ember 2.13 to 3.18 and I’ve fixed mostly all changes. But there is an issue with preventing changing the route.
My old code was look like:
`currentPathDidChange: function () {
var that = this;
schedule('afterRender', this, function () {
if (that.currentRouteName === 'userform') {
window.onbeforeunload = function () {
return 'Changes that you made may not be saved.';
};
}
}); }.observes('currentPath')`
Preventing transitions is probably necessary but not sufficient by itself.
Preventing transitions will stop the user from moving within the Ember app, but it won’t stop them from leaving the Ember app entirely and going to some other web page. For that you still need window.onbeforeunload. So the main question is, where to install and uninstall the onbeforeunload handler.
I like to tie this kind of thing to the lifetime of some particular place in the DOM, because there must be something on screen that is the reason you’re stopping the user, and that place is where it’s good to control the interruption from. So you can make a modifier like this: