4
votes

emberjs-1.0.0-rc-6.1

My controller :

Application.LoginController = Ember.Controller.extend({
        loginFailed: false,
        isProcessing: false,
        isSlowConnection: false,
        timeout: null,
        login: function() {
            /* some code */
        },
        success: function() {
            this.reset();
        },
        failure: function() {
            this.reset();
        },
        reset: function() {
            clearTimeout(this.get("timeout"));
            this.setProperties({
                isProcessing: false,
                isSlowConnection: false
            });
        }
    });

My Routing :

Application.LoginRoute = Ember.Route.extend({
        setupController: function(controller, model) {
            controller.reset();
        },
        events: {
        }
    });

When I go to "/login" for the first time, setupController is called. However, I would like to use a event (like transition) to call controller.reset() everytime Application transition into login.

With LOG_TRANSITIONS: true

I can see "Transitionned into 'login'", "Transitionned into 'anotherPage'" in the console, so I would like to know if it's possible to get the event which trigger those logs, in my router.

Like :

Application.LoginRoute = Ember.Route.extend({
        setupController: function(controller, model) {
            controller.reset();
        },
        events: {
            didTransition: function(reason) {
                 controller.reset();
            }
        }
    });
1

1 Answers

3
votes

I would like to know if it's possible to get the event which trigger those logs, in my router.

You can hook into to the route's activate and deactivate hooks and call the controller methods from there, like this:

Application.LoginRoute = Ember.Route.extend({
  activate: function() {
    this.controllerFor('login').send('reset');
  },
  deactivate: function() {
    this.controllerFor('login').send('reset');
  }
});

Hope it helps.