Skip to content

Instantly share code, notes, and snippets.

@RyanHirsch
Created January 15, 2015 17:09
Show Gist options
  • Select an option

  • Save RyanHirsch/9706032836aae78d6407 to your computer and use it in GitHub Desktop.

Select an option

Save RyanHirsch/9706032836aae78d6407 to your computer and use it in GitHub Desktop.
note/edit action

I have a lock action defined on my notes route. When I navigate directly to note/edit and the this.send('lock', model); throws an error because nothing handled it, but when I go to note and click the edit button the action goes to the notes route and it all works as I expect. Why is the action handled differently on a direct navigation to note/edit compared to note then clicking edit?

// note/edit/route.js
export default Ember.Route.extend({
afterModel: function(model) {
if(!model.get('canEdit')) {
this.transitionTo('note', model);
}
else {
this.send('lock', model);
}
}
});
Router.map(function() {
this.resource('notes', { path: '/' }, function() {
this.resource('note', { path: '/:note_id' }, function() {
this.route('edit');
});
this.route('new');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment