Skip to content

Instantly share code, notes, and snippets.

@th3hamburgler
Created June 23, 2021 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save th3hamburgler/365933eceb8cf84aa8f836d85d2b2562 to your computer and use it in GitHub Desktop.
Save th3hamburgler/365933eceb8cf84aa8f836d85d2b2562 to your computer and use it in GitHub Desktop.
import Route from '@ember/routing/route';
import { action } from '@ember/object';
export default class FormRoute extends Route {
@action
willTransition(transition) {
if (this.controller.userHasEnteredData &&
!confirm('Are you sure you want to abandon progress?')) {
transition.abort();
} else {
// Bubble the `willTransition` action so that
// parent routes can decide whether or not to abort.
return true;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment