Created
October 2, 2015 15:31
-
-
Save mguterl/565cf6183c8dfd49af2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
var inject = Ember.inject; | |
export default Ember.Route.extend({ | |
history: inject.service(), | |
beforeModel: function(transition) { | |
// capture the first page load | |
this.get('history').capture(transition); | |
}, | |
actions: { | |
willTransition: function(transition) { | |
this.get('history').capture(transition); | |
}, | |
goBack: function() { | |
var previousTransition = this.get('history.previous'); | |
if (previousTransition) { | |
this.get('history').capture(previousTransition); | |
previousTransition.retry(); | |
} else { | |
this.transitionTo('home'); | |
} | |
}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is an idea giving the history service more responsibility and removing the history concern from the application route. https://gist.github.com/mitchlloyd/9def667b38a8da9558d4