Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
App.PostsController = Em.ArrayController.extend({
actions: {
create: function () {
// some validation logic here
return this.send('createPost');
},
save: function (model) {
// some validation logic here
return this.send('savePost');
},
delete: function (model) {
// some validation logic here
return this.send('deletePost');
}
}
});
App.PostsRoute = Em.Route.extend({
actions: {
createPost: function () {
var post = store.createRecord( /* stuff here */ );
post.save().then(function (result) {
// some sucecss handling
}, function(error) {
// some error handling
});
},
savePost: function(model) {
model.save().then(function (result) {
// some sucecss handling
}, function(error) {
// some error handling
});
},
deletePost: function(model) {
model.deleteRecord();
model.save().then(function (result) {
// some sucecss handling
}, function(error) {
// some error handling
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment