1

我遇到有关下拉菜单无法在移动设备上工作的问题,我一直在努力工作一周。我从bootstrap网站获取了当前示例的一个副本,对其进行了一些修改,在测试期间我发现它并未按预期工作。 (原来的例子也是如此(http://twitter.github.io/bootstrap/examples/carousel.html),我只添加了一个链接,例如谷歌) - 为什么这种行为?自举导航崩溃链接无法在移动设备上工作

<div class="navbar navbar-inverse navbar-fixed-top"> 
    <div class="navbar-inner"> 
    <div class="container"> 
     <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> 
     <span class="icon-bar"></span> 
     <span class="icon-bar"></span> 
     <span class="icon-bar"></span> 
     </button> 
     <a class="brand" href="#">Dropdown test</a> 
     <div class="nav-collapse collapse"> 
     <ul class="nav"> 
      <li class="dropdown"> 
      <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-target="#">Links<span class="caret"></span></a>  
      <ul class="dropdown-menu"> 
       <li><a href="http://www.google.com" target="blank">Google (opens in new window)</a></li> 
       <li><a href="http://www.bing.com" target="blank">Bing (opens in new window)</a></li> 
       <li><a class="linkcheck" href="http://www.google.com">Google</a></li> 
       <li><a class="linkcheck" href="http://www.bing.com">Bing</a></li> 
      </ul> 
      </li><!-- .dropdown --> 
     </ul><!-- .nav --> 
     </div><!-- .nav-collapse --> 
    </div><!-- .container --> 
    </div><!-- .navbar-inner --> 
</div><!-- .navbar --> 

引导是新的给我,我找不到导航崩溃的任何文件,我在哪里可以找到呢? 我真的必须做点击事件,然后window.open(url)? (或根本的onclick行为在移动设备上的不同?)

这是我在网上例如:http://test-web.dk/sandbox/bootstrap/

编辑: 找到了解决办法:

$('.linkcheck', this).click(function(){ 
    var url = $(this).attr('href'); 
    alert("link clicked:" + url); 
    if(url.match(/^http:/)) { 
    window.location.href = url; 
    } 
}); 

// fix by RobDodson: github.com/twitter/bootstrap/issues/4550 
// Kills regular links in browsers though, but they will be redirected by linkcheck above 
$('.dropdown a').click(function(e) { 
    e.preventDefault(); 
    setTimeout($.proxy(function() { 
    if ('ontouchstart' in document.documentElement) { 
     $(this).siblings('.dropdown-backdrop').off().remove(); 
    } 
    }, this), 0); 
}); 

不过,真正的自举解决方案将是不错的知道,而不是一个黑客:-)所以,如果有人有一个建议,请张贴它。

+0

另一个简单的修复:https://github.com/Bitergia/bootstrap/commit/25e8eeb –

回答

2

检查您使用的是最新的jQuery。

我与Drupal的Bootstrap主题有同样的问题,但通过将jQuery Update中的设置更改为最新版本来解决此问题!

相关问题