简体   繁体   English

twitter bootstrap下拉链接不起作用

[英]twitter bootstrap dropdown links not working

I am using bootstrap version 2.0 我正在使用bootstrap 2.0版

I have the following html structure - 我有以下html结构 -

Now when I click on the Filter by Team the dropdown shows properly. 现在,当我点击Filter by Team下拉菜单显示正确。 Now when I click on the link, I should be taken to the page. 现在当我点击链接时,我应该被带到页面。 But the links do not work. 但链接工作。 I mean, when I click on the dropdown elements, they should take me to a url, which they are href'ed to, this does not happen. 我的意思是,当我点击下拉元素时,他们应该把我带到一个网址,这是他们所反映的,这不会发生。

<li style="margin-left: 12px;">
        <div class="dropdown" style="margin-top: 5px;">
          <a class="dropdown-toggle" style="margin-left: -2px;" data-toggle="dropdown" href="#">
            Filter by Team
          </a>
          <ul class="dropdown-menu" data-toggle="dropdown" role="menu" aria-labelledby="dropdownMenu">

            <li>
              <a tabindex="-1" class="disabled" href="/task/list/orgteam/8/">funvilla</a>
            </li>
            <li class="divider"></li>

            <li>
              <a tabindex="-1" class="disabled" href="/task/list/orgteam/6/">Dev Team</a>
            </li>
            <li class="divider"></li>

            <li>
              <a tabindex="-1" class="disabled" href="/task/list/orgteam/5/">Design Team</a>
            </li>
            <li class="divider"></li>


          </ul>
        </div>
      </li>

The fiddle can be found here - http://jsfiddle.net/ktgrw/ 小提琴可以在这里找到 - http://jsfiddle.net/ktgrw/

The problem is that you have the data-toggle attribute set for the <ul> , that attribute is just for the link that you want to open/close the dropdown, remove it and the links should work. 问题是您已为<ul>设置了data-toggle属性,该属性仅适用于您要打开/关闭下拉列表的链接,删除它并且链接应该有效。

Here's the updated fiddle with the correct bootstrap version and the attribute removed. 这是更新的小提琴 ,正确的bootstrap版本和删除的属性。

Also the disabled class is used on the toggle link to prevent the opening of the dropdown, you should remove it from your links since it's not serving any real purpose. 此外,在切换链接上使用disabled类来阻止打开下拉列表,您应该将其从链接中删除,因为它没有任何实际用途。

The links are working perfectly fine. 链接工作得非常好。 When we use relative links like href="/task/list/orgteam/5/" we need to be sure that we are running this page on a website where these links exist. 当我们使用像href="/task/list/orgteam/5/"这样的相对链接时,我们需要确保我们在存在这些链接的网站上运行此页面。

To add to clarity, I added a link to google as the last list item in this new fiddle (click here to view) and because it uses absolute url href="http://www.google.com" , it works just fine. 为了增加清晰度,我添加了一个谷歌链接作为这个新小提琴中的最后一个列表项(点击此处查看) ,因为它使用绝对url href="http://www.google.com" ,它工作得很好。

I faced same problem with bootstrap framework and at the end got the solution (worked for me). 我遇到了与bootstrap框架相同的问题,最后得到了解决方案(为我工作)。 Import all your required javascripts, mainly jquery.js . 导入所有必需的javascripts,主要是jquery.js

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

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