Skip to content

Instantly share code, notes, and snippets.

@kellysutton
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellysutton/8074a30aa0d3d783c8a3 to your computer and use it in GitHub Desktop.
Save kellysutton/8074a30aa0d3d783c8a3 to your computer and use it in GitHub Desktop.
Reducing “action cruft” in your Ember templates
{{post-detail post=post}}
// app/components/post-detail.js
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
startEditing: function () {
this.get('targetObject').send('startEditing', this.get('model'));
}
}
});
// app/controllers/posts/show.js
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
startEditing: function (post) {
// Perform the logic to start editing the post
}
}
});
{{post-detail post=post
closeModal='closeModal'
startEditing='startEditing'
stopEditing='stopEditing'
publish='publish'
save='save'}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment