cyclomarc
cyclomarc

Reputation: 2012

Ember: Regression in rc7 - transitionTo in route activate no longer works as expected

For translation purposes, I need to switch to a route in which I do some initialisation of the new language settings and then transition back to the initial application page.

See a working example with Ember rc6 on http://jsfiddle.net/cyclomarc/dpDuM/2/

Flow: When clicking Show page1, show the contents of page 1, when clicking on Update language, transition to i18Redirect route and in this route activate, transition to page 2. thus, after the transition, the shown page should be page 2.

In Ember rc7, this no longer works. See JSFiddle of same codde on http://jsfiddle.net/cyclomarc/p3yVP/1/

App.I18redirectRoute = Ember.Route.extend({
  activate: function () {
    alert("Arrived in i18Redirect route > Do transition to page 2")
    this.transitionTo('page2');
  }
});

The console log indicates "transitioned into page2', but the URL and the view show a blank page. It looks like the page 2 content is not rendered in the outlet (in my sample, the outlet has a red border).

Is this a regression ?

Upvotes: 0

Views: 199

Answers (2)

cyclomarc
cyclomarc

Reputation: 2012

Thanks to the answer on http://discuss.emberjs.com/t/ember-regression-in-rc7-transitionto-in-route-activate-no-longer-works-as-expected/2217/2, the problem is found.

I need to use the afterModel hook on the route and not the activate hook to do a transition; So this works:

App.I18redirectRoute = Ember.Route.extend({
    afterModel: function() {
        this.transitionTo('page2');
    }
});

Upvotes: 0

Geraud Mathe
Geraud Mathe

Reputation: 711

In the last versions of ember , a deprecation warning was thrown when using transitionTo, the changelog is not giving infos about transitionTo though the rc7 is the first version without the old router (EMBER 1.0 RC7 RELEASED ), the new way of using it is to call this.transitionToRoute

Upvotes: 1

Related Questions