emberjs - how to mark active menu item using router infrastructure

前端 未结 15 1472
悲&欢浪女
悲&欢浪女 2020-11-27 13:06

I\'m trying to create navigation tabs (taken from Twitter Bootstrap):

15条回答
  •  离开以前
    2020-11-27 13:49

    Here's a full working solution:

    View:

    App.NavView = Ember.View.extend({
      tagName: 'li',
      classNameBindings: ['active'],
    
      active: function() {
        return this.get('childViews.firstObject.active');
      }.property()
    });
    

    Template:

      {{#each item in controller}} {{#view App.NavView}} {{#linkTo "item" item tagName="li"}} {{ item.name }} {{/linkTo}} {{/view}} {{/each}}

提交回复
热议问题