An add-on to conditionally prompt the user when transitioning between routes or closing the browser.
This library is tested against Ember 1.13.x and Ember 2.x.
ember install ember-onbeforeunload
To get started, mix the
ConfirmationMixin into your
Ember.Route. By default,
the user will be prompted beforeunload any time the
model for the route
This addon tries to provide sane defaults, but it also exposes all of the internals for customization.
You can customize the message displayed in the confirmation dialog by overriding
confirmationMessage property. You can either pass a hard-coded string,
or use a function.
If you do not sure Ember Data, or you have other logic to determine whether or
not the page is dirty, you can override the
Allow Dirty Transitions
By default, we allow navigating within the hierarchy of route you mix the
ConfirmationMixin into. For example, navigating from
myroute.index.subroute would not check
isPageDirty. If you have other logic
that determines when a dirty transition should be allowed, you can override
If you have some custom logic you'd like to execute when your route is unloaded,
you can tie into the
onUnload function. By default, this function is a no-op.
This library underwent major API changes with version 1.0.0. For information on how to upgrade, please check out UPGRADING.md.
Found a bug? Please report it!
git clonethis repository
npm run lint:js
npm run lint:js -- --fix
ember test– Runs the test suite on the current Ember version
ember test --server– Runs the test suite in "watch mode"
npm test– Runs
ember try:eachto test your addon against multiple Ember versions
Running the dummy application
- Visit the dummy application at http://localhost:4200.
For more information on using ember-cli, visit http://www.ember-cli.com/.