Last active
August 29, 2015 13:58
-
-
Save praxxis/10213697 to your computer and use it in GitHub Desktop.
Observing parent controller model changes to reset content
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.CommentsNewController = Em.ObjectController.extend({ | |
// create an empty comment when this controller is first created, and when its parent controller changes its model | |
createNewComment: function () { | |
this.set('model', DS.Comment.create()); // I don't use Ember Data so this might not be correct | |
}.on('init').observes('parentController.model'), // `parentController` is a relationship set up by `render` | |
actions: { | |
save: function () { | |
var comment = this.get('model'); | |
comment.save(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment