Created
November 2, 2014 16:43
-
-
Save ultimatemonty/d6e140f72b24e736cea2 to your computer and use it in GitHub Desktop.
This gist was an attempt to work around https://github.com/emberjs/ember.js/issues/5264 that failed. wanted to save it for later reference if needed.
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
App.ApplicationRoute = Ember.Route.extend({ | |
actions: { | |
back: function (path, model) { | |
console.log('APPLICATION.BACK'); | |
var transitionObject = App.Transition.create({ 'path': path, 'objectId': model.get('id') }); | |
this.transitionTo('transition', transitionObject); | |
} | |
} | |
}); |
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
App.Router.map(function() { | |
this.route('transition', { path: ':path/:object_id' }); | |
} |
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
App.Transition = Ember.Object.extend({ | |
path: null, | |
objectId: null | |
}); |
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
App.TransitionRoute = Ember.Route.extend({ | |
serialize: function (params) { | |
return { path: params.path, objectId: params.object_id }; | |
}, | |
afterModel: function (model, transition) { | |
this.set('path', model.get('path')); | |
this.set('objectId', model.get('objectId')); | |
}, | |
setupController: function () { | |
console.log("TRANSITIONING"); | |
var path = this.get('path'); | |
var objectId = this.get('objectId'); | |
if (objectId) { | |
this.transitionTo(path, objectId); | |
} else { | |
this.transitionTo(path); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment