简体   繁体   English

Ember.js引导活动选项卡

[英]Ember.js Bootstrap Active Tab

I am using Ember.js and Bootstrap to create an app. 我正在使用Ember.js和Bootstrap创建一个应用程序。 The app has 2 routes accounts.devices.devices1 and accounts.devices.devices2. 该应用程序有2条路由accounts.devices.devices1和accounts.devices.devices2。 I don't need the route accounts.devices but it can exist if necessary. 我不需要路由account.devices,但如有必要,它可以存在。 But there should not be a link to it. 但是不应该有链接。 I am running into issues with active. 我遇到了主动问题。 The link to Devices 1 is set as active when on the accounts.devices.devices1 page but I also want the link to accounts.devices. 在accounts.devices.devices1页面上,到设备1的链接设置为活动,但我也希望到accounts.devices的链接。 Basically whenever a child in the dropdown is active, I also want the parent to be active. 基本上,无论何时下拉列表中的一个孩子处于活动状态,我都希望父母处于活动状态。 This doesn't set the parent active only the child: 这不会将父级设置为仅激活子级:

<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Devices<span class="caret"></span></a>
  <ul class="dropdown-menu">
    {{#link-to 'accounts.devices.devices1' tagName='li'}}<a href={{view.href}}>Devices 1</a>{{/link-to}}
    {{#link-to 'accounts.devices.devices2' tagName='li'}}<a href={{view.href}}>Devices 2</a>{{/link-to}}
  </ul>
</li>

This code sets the parent active but also creates a link to accounts.devices when the dropdown is clicked instead of opening the dropdown. 此代码将父级设置为活动状态,但在单击下拉列表而不是打开下拉列表时,也会创建到accounts.devices的链接。 Also, the links to Devices 1 and Devices 2 don't work. 此外,指向设备1和设备2的链接也无效。

{{#link-to 'accounts.devices' tagName='li' class='dropdown'}}
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Devices<span class="caret"></span></a>
  <ul class="dropdown-menu">
    {{#link-to 'accounts.devices.devices1' tagName='li'}}<a href={{view.href}}>Devices 1</a>{{/link-to}}
    {{#link-to 'accounts.devices.devices2' tagName='li'}}<a href={{view.href}}>Devices 2</a>{{/link-to}}
  </ul>
{{/link-to}}

How should this be done? 应该怎么做?

Add disabled=true to the top-level link-to : disabled=true添加到顶级link-to

{{#link-to 'accounts.devices' tagName='li' disabled=true class='dropdown'}}
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Devices<span class="caret"></span></a>
  <ul class="dropdown-menu">
    {{#link-to 'accounts.devices.devices1' tagName='li'}}<a href={{view.href}}>Devices 1</a>{{/link-to}}
    {{#link-to 'accounts.devices.devices2' tagName='li'}}<a href={{view.href}}>Devices 2</a>{{/link-to}}
  </ul>
{{/link-to}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM