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);
});
不过,真正的自举解决方案将是不错的知道,而不是一个黑客:-)所以,如果有人有一个建议,请张贴它。
另一个简单的修复:https://github.com/Bitergia/bootstrap/commit/25e8eeb –