javascript - Twitter Bootstrap 下拉事件未在触摸设备上触发

标签 javascript jquery twitter-bootstrap touch-event

下拉菜单可以正常打开和关闭,但不会触发点击事件/或触摸事件。我整理了一个小测试用例 demo但它同样容易运行 twitter bootsrap docs .我已经在 Android 和 iOS 设备上尝试过。

我希望通过包含事件库(如 jQueryMobile 或 Hammer.js)来纠正,但我不确定这是否会有所帮助,因为 Twitter Bootstap(我认为)包含其自己的触摸处理程序。

还有其他人遇到过这个问题吗?

最佳答案

为了解决这个问题,我使用了 Jquery Mobile 触摸事件并在下拉列表中监听了 tapevents。这是一个简单的实现:

            $(".dropdown-menu").on("tap", "li a", function(e, ui){
                e.preventDefault();

                if ($(this).attr("data-toggle") === "modal")
                {
                     $($(this).attr('href')).modal("show");
                }

                return false;
            })

关于javascript - Twitter Bootstrap 下拉事件未在触摸设备上触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12687792/

相关文章:

javascript - 背景颜色在手机上消失

javascript - 使用 animate css 按顺序动画元素

javascript - PhoneGap/Cordova "click"在浏览器中工作,但不在 Developer App 上工作?

html - page-break-inside 用于可打印页面

html - 向上移动图标并与我的主标题内联

javascript - 如何在cakephp中调用 View 文件中的函数?

javascript - ng重复:dupes Error when entering nulls in array

Javascript onchange 表单

css - Bootstrap 中的中心侧边栏内容

javascript - 当存在 Parsley 错误 div 时,带有国际电话输入的标志向下移动