Skip to content

Instantly share code, notes, and snippets.

@ultimatemonty
Created November 2, 2014 16:43
Show Gist options
  • Save ultimatemonty/d6e140f72b24e736cea2 to your computer and use it in GitHub Desktop.
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.
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);
}
}
});
App.Router.map(function() {
this.route('transition', { path: ':path/:object_id' });
}
<button class="btn bg-primary bg-flat" {{action 'back' 'path.to.route' model}}>Back</button>
App.Transition = Ember.Object.extend({
path: null,
objectId: null
});
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