为什么Bootstrap按钮下拉在iOS上不起作用? [英] Why doesn't Bootstrap button dropdown work on iOS?

查看:849
本文介绍了为什么Bootstrap按钮下拉在iOS上不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使是这里的启动演示,也无法在iOS上运作。您似乎无法在iPhone或iPad上从中选择项目。

It looks like even the bootstrap demo here doesn't work on iOS. You don't seem to be able to select an item from it on iPhone or iPad.

这是否有修复?

推荐答案

有一个快速修复,在github的很多问题评论中指出:
https://github.com/twitter/bootstrap/issues/2975#issuecomment-8670606

There is a quick fix as noted in many of the issue comments on github: https://github.com/twitter/bootstrap/issues/2975#issuecomment-8670606

在你的关闭html标签之前添加这个脚本:

add this script just before your close html tag:

$('body').on('touchstart.dropdown', '.dropdown-menu', function (e) { 
    e.stopPropagation(); 
});

我在ios5和6上测试了上面的方法。它像一个charm

I have tested the above method on both ios5 and 6. It works like a charm

如果你想修改bootstrap的javascript,你可以,而不是上面的修复,删除touchstart.dropdown.data-api从

If you wish to modify the bootstrap javascript you could, instead of the fix above, remove touchstart.dropdown.data-api from the html binding for clearMenus near the bottom of the file.

只要更改

$('html')
  .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)

$('html')
  .on('click.dropdown.data-api', clearMenus)

这篇关于为什么Bootstrap按钮下拉在iOS上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆