0

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 ?

4

2 回答 2

1

在 ember 的最后一个版本中,使用时抛出了弃用警告transitionTo,虽然 rc7 是第一个没有旧路由器的版本(EMBER 1.0 RC7 RELEASED ),但更新日志没有提供有关 transitionTo 的信息,使用它的新方法是调用this.transitionToRoute

于 2013-08-19T09:27:07.693 回答
0

感谢http://discuss.emberjs.com/t/ember-regression-in-rc7-transitionto-in-route-activate-no-longer-works-as-expected/2217/2上的答案,问题是成立。

我需要在路由上使用 afterModel 钩子而不是 activate 钩子来进行转换;所以这有效:

App.I18redirectRoute = Ember.Route.extend({
    afterModel: function() {
        this.transitionTo('page2');
    }
});
于 2013-08-19T10:58:26.183 回答