Question

If I delete a record in my app I need to reload the corresponding model. How am I able to accomplish that? Just to remove the entry is not a solution because I use serverside- pagination. For that reason I want the model complete reloaded after the deletion.

Is it possible to reload the model defined in the route?

PS: I don't use ember data...

Was it helpful?

Solution 2

The only working way to update the model from the controller is to use this.set("model",result); I found no way to reload the model, so I did this in my controller:

 actions: {
      remove : function(user) {
        var self = this;
        bootbox.confirm(user.username+" wirklich löschen?", function(result) {
         if(result == true) {
             App.Model.remove(user,"/api/user/"+user.id).done(function (response) { 

                  var returnPage = self.get('meta').pagination.page;                     

                  // To Do: Check if the deletet entry was the last one on the page. It true go returnPage -1 if returnPage > 0     
                  App.Model.get(self,"users.page","/api/users/list/"+returnPage).done( function (result) {
                      self.set("model", result);
                  });
             });   
          }
        });
      }
    }

OTHER TIPS

transition to the route with the new model, or update the individual properties on the model.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top