-
-
Save cmosguy/b244b8daace520494cbc to your computer and use it in GitHub Desktop.
This file contains 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.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