ember-data-route
v0.2.0
Published
Ensure you clean up after your models. Any routes you deactivate will check the model to ensure it is not unsaved. If it is it will either rollback or remove the model from the store depending if has been previously persisted.
Downloads
195
Readme
Ember Data Route
About
Ensure you clean up after your models.
Any routes you deactivate will check the model
to ensure it is not
unsaved. If it is it will either rollback or remove the model from the
store depending if has been previously persisted.
Install
npm install ember-data-route --save-dev
Usage
Add the mixin to any route you want:
import Ember from 'ember';
import DataRoute from 'ember-data-route';
export default Ember.Route.extend(DataRoute, {
...
});
Transition Confirmation
By default when you transition out of the route the data model is
rolled-back/removed automatically after the router is deactivated.
However, you may want to detect if this is going to happen and alert the
user of changes that will be lost. Typically you could use
window.confirm
to allow the user to decide to proceed or not. In the
route you are mixing into you can provide your own
willTransitionConfirm
function to handle this. By default this
function returns true
and is passed the transition
object as an
argument for you to handle. One possible override could be:
export default Ember.Route.extend(DataRouteMixin, {
willTransitionConfirm: function() {
return window.confirm("You have unsaved changes that will be lost. Do you want to continue?");
}
});
Authors
We are very thankful for the many contributors
Versioning
This library follows Semantic Versioning
Want to help?
Please do! We are always looking to improve this gem. Please see our Contribution Guidelines on how to properly submit issues and pull requests.
Legal
DockYard, Inc © 2014