0

My ember router looks like this:

Ew.Router.map ->
  @.resource "about", ->
    @.route "philosophy"
    @.route "leadership"
    @.route "staff"
    @.route "affiliations"
  @.route "conditions"
  @.route "programs"
  @.route "testimonials"

In application.hbs I have a nav bar and when you click 'ABOUT' a subnav displays with subpage links. I would like 'ABOUT' to link to 'philosophy.hbs' instead of 'about/index.hbs'. However, when I do this the 'active' class shows up on 'ABOUT' on the main nav, and 'PHILOSOPHY' on the subnav, which is correct. However, as soon as I click on another subpage of about, the 'active' class on 'ABOUT' disappears and only displays on the subnav link.

The only way I can get the 'active' class to always display on the main nav 'ABOUT' is to have an 'about/index.hbs' page. But due to the architecture of the site i really need 'philosophy.hbs' to be the main about landing page and not 'index'

Any ideas why this is breaking the 'active' state, even though the url still reads '/about/leadership', '/about/staff', etc? I would think as long as /about is in the url the active state on that link should be active.

4

2 回答 2

1

我认为您需要将重定向添加到将显示 Philosophy.hbs 的 about 路由

App.AboutRoute = Ember.Route.extend({
  redirect: function(){
    this.transitionTo('about.philosophy');
  }
});

我有一个创建jsbin让我知道它是否有效。

干杯

于 2013-09-09T22:09:19.993 回答
0

您是否尝试过指定路线上的路径?

App.Router.map(function() {


this.resource('philosophy', { path: '/about' },  function() {
    this.route('leadership');
    // other routes
  });
});

这个 JSBin 是否捕获了您正在尝试做的事情?http://jsbin.com/UYIraQO/1/edit

于 2013-09-09T22:19:05.467 回答