Last active
August 29, 2015 14:03
-
-
Save robyurkowski/34b71e59cfdeace9767e to your computer and use it in GitHub Desktop.
sending reload to parent route
This file contains hidden or 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.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. | |
}, | |
}); |
This file contains hidden or 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.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