I would like to find the same bloggr tutorial but without ember data. I have some pbs to correctly manage the JSON/REST calls to the server and the model synchronisation after a remove/add operation
I would like:
- Create a simple table displaying all posts from the server
- Delete a post from a button linked to each post in the table
- After the deletion, I need to sync the server side but also update the current table to remove the deleted post only if delete on server is OK
What I have done:
-
Create the model
App.Post = Ember.Object.extend();
-
Create a PostStore with CRUD REST/JSON operation with the backend
App.CertificateStore.reopenClass({
all: function() {//REST/JSON call to the backend returning array of posts}
delete: function(post) { //REST/JSON call to the backen to delete the post}
}
-
Create the PostsRoute to associate the model
App.PostsRoute = Ember.Route.extend({
model: function() {
return App.PostStore.all();
} });
-
Create the PostsController
App.PostsController = Ember.ArrayController.extend({ deletePost: function(certificate) { App.PostStore.delete(certificate); } });
My Questions
-
As the model is directly linked to the call with the REST/JSON call, how to sync this model and update the table when I remove a post with the delete method ?
-
Do I need to make a call to the server to get the new list of posts after removing a post or it could be done smoothy on the client side ?