简体   繁体   English

Twitter引导下拉事件未在触摸设备上触发

[英]Twitter Bootstrap Dropdown events Not Firing on Touch Devices

The dropdown opens and closes fine but the click event / or touch event isn't being fired. 下拉列表打开并关闭正常,但未触发click事件/触摸事件。 I put together a tiny test case demo but its just as easy to run the twitter bootsrap docs . 我整理了一个小小的测试案例演示,但它同样容易运行twitter bootsrap文档 I have tried this on Android and iOS devices. 我在Android和iOS设备上试过这个。

I was hoping to rectify by including an Events library like, jQueryMobile or Hammer.js but I'm not sure if this will help as Twitter Bootstap (I think) includes its own touch handlers. 我希望通过包括像jQueryMobile或Hammer.js之类的事件库来纠正,但我不确定这是否会有所帮助,因为Twitter Bootstap(我认为)包括自己的触摸处理程序。

Anyone else come across the problem? 还有其他人遇到过这个问题吗?

As a work around to this problem I used the Jquery Mobile touch events and listened for tapevents on the dropdown. 作为解决此问题的方法,我使用了Jquery Mobile触摸事件并在下拉列表中侦听了tapevents。 Here is a simple implementation: 这是一个简单的实现:

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

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

                return false;
            })

Seems to be a known issue that's resolved in bootstrap 2.1.2 - https://github.com/twitter/bootstrap/pull/5054 . 似乎是在bootstrap 2.1.2中解决的已知问题 - https://github.com/twitter/bootstrap/pull/5054

Edit: tried to apply the changes in the ticket about, but couldn't get it to work either. 编辑:尝试应用票证中的更改,但无法使其工作。

@CrimsonChin - can you pls elaborate on your implementation. @CrimsonChin - 你能详细说明你的实施吗? I tried your code, but using JQM with bootstrap I get all kinds of weird behaviors. 我尝试了你的代码,但是使用JQM和bootstrap我会得到各种奇怪的行为。

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

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