0
votes

In my application, I have the standard parent/children routes relationship. I want to execute a function every time the user clicks (via {{link-to}}) into a new route. I've tried implementing this function in the parent and children routes' activate hook, but the function is called only when the application first starts, and not called during subsequent route transition.

Is there a way to tell Ember to execute a function every time the user transitions into a new route?

1

1 Answers

2
votes

There is a willTransition action, that is called when a transition is made. You can use the following to get all transitions:

App.ApplicationRoute = Ember.Route.extend({
    actions: {
        willTransition: function(transition) {
            console.log('Transitioning to', transition.targetName);
        }
    }
});

This is a fiddle with this in action http://jsfiddle.net/marciojunior/Cs7S6/