Reload the model after transitionTo or ransition retry

Hi there,

I’m new to Ember and i’m struggling for a long time with this problem. I have built an Ember app which communicates with a RESTful Nodejs server. First i have a handlebar template with an action ‘add’:

 {{#if completed}}
        <div class="text">
            <p>{{content.name}}</p></br>
            <p>gedaan door: {{content.completed_by}}</p></br>
            <p>klus afgemeld op: {{content.end_date}}</p>
        </div>
        <ul class="meta">
            <li class="price">&euro;{{content.amount}}</li>
        </ul>
	{{else}}
        <div class="text">
            <p>{{content.name}}</p></br>
            <p>gedaan door: {{content.completed_by}}</p></br>
            <p>toegevoegd op: {{content.start_date}}</p>
        </div>
        <ul class="meta">
            <li class="price">&euro;{{content.amount}}</li>
        </ul>
         <button {{action 'add'}}>Klus afmelden</button>
    {{/if}}

Here is the app.js code with the action (don’t know why the formatting breaks, sorry for that):

App.KlusBySavingtargetRoute = App.AuthenticatedRoute.extend({
    serialize: function(model, params) {
        return {
            klus_id: model._id
        };
    },
    actions: {
        add : function(){
            var now = new Date();
            var jsonDate = now.toJSON();
            var previousTransition = this.controllerFor('login').get('previousTransition');
            var controller = this.get('controller');
        var klus ={
            _id: this.currentModel._id,
            task_id: this.currentModel.task_id,
            completed_by: this.currentModel.doneBy,
            amount: this.currentModel.amount,
            completed: true,
            end_date: jsonDate
        };
        var userModel = App.User.find('538314b86cca49020073e969', function (response) {
            if(response.savingtargets != null)
            {
                response.savingtargets.forEach(function (savingtarget) {
                    // get the current savingtarget, it's not completed yet
                    if(savingtarget.completed == false)
                    {
                        savingtarget.tasks.forEach(function(task){
                            if(task._id == klus._id)
                            {
                                task.completed = true;
                                task.end_date = jsonDate;
                            }
                        });
                    }
                });
            }

            App.User.save(response, function(user){
                //controller.transitionTo('doelByUser', '538314b86cca49020073e969');
                previousTransition.retry();
                this.controllerFor('login').set('previousTransition', transition);
            });
        });
    };
}
});

After is save my User model i want to redirect the user to the previous screen. In this case it’s going to the following route:

App.DoelByUserRoute = App.AuthenticatedRoute.extend({
    beforeModel: function(transition) {
        var loginController = this.controllerFor('login');
        loginController.set('previousTransition', transition);
    },
    model: function(params) {
        var user = App.User.findSavingTarget('538314b86cca49020073e969', params.doel_id);
        return user;
    },
    serialize: function(model, params) {
        return {
            doel_id: model._id
        };
    }
});

The problem is that i want the model to reload. Now i’m getting the same data as before but i have adjust the user model in the action ‘add’. I thought this should work, but it doesn’t work:

 afterModel: function(model) {
        this.model.reload();
    }

I hope you guys can help my with this.

Off: I love EmberJs but i’m struggling with a lot when using a RESTful Nodejs server and not using Ember-data.