Ember: Get route instance from the controller

From within a controller, you can access the router via this.get('target'). So this.get('target').send('goToNextStep') should work.

Like so:

App.Flow = Em.ObjectController.extend({
  submit: function(){
    // ...
    this.get('target').send('gotoNextStep');
  }
}

App.FlowRoute = Ember.Route.extend({
  events: {
    gotoNextStep: function(){
      // ...
      this.transitionTo(routeName);
    }
  }
}

You need to get the route for such conditions, so from the controller just say,

App.Flow = Em.ObjectController.extend({
  submit: function(){
    var self =this;
    // Validation and XHR requests
    // ...

    // Go to the next step
    self.send('goToNextStep');
  }
}

and define your goToNextStep event in your route's event hash

Tags:

Ember.Js