Skip to content

Instantly share code, notes, and snippets.

@robyurkowski
Last active August 29, 2015 14:03
Show Gist options
  • Save robyurkowski/34b71e59cfdeace9767e to your computer and use it in GitHub Desktop.
Save robyurkowski/34b71e59cfdeace9767e to your computer and use it in GitHub Desktop.
sending reload to parent route
App.CommentsNewRoute = Ember.Route.extend({
model: function() {
return this.store.createRecord('comment', {post: this.modelFor('post')});
},
actions: {
save: function() {
var model = this.modelFor('commentsNew');
model.save().then(
this.saveSucceeded.bind(this),
this.saveFailed.bind(this)
);
},
},
saveSucceeded: function() {
// This bubbles up to PostRoute, assuming it is a parent of the child route
this.send('modelShouldRefresh');
},
saveFailed: function() {
// Whine.
},
});
App.PostRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('post', params.post_id);
},
actions: {
modelShouldRefresh: function() {
this.refresh();
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment