Categories: Blog

Twitter Bootstrap dropdown hover touch devices workaround (iPad, iPhone, Galaxy, etc…)

UPDATE 11/01/2013: Thanks to Robin for pointing this out, the recent Bootstrap 2.2.2 release has addressed this issue. Refer to their changelog for details.

Ran into an issue today during development where I was updating my company’s code source from Twitter Bootstrap 2.03 to 2.2.1.

All was fine and dandy until I was doing some cross-device testing, specifically on the iPad and the iPhone.

The touch events stopped working on the Twitter Bootstrap dropdown hover menus. When you try to click on the menu item and attempt to swipe down or anywhere, the menu would disappear.

This is also happening on the official examples and Twitter Bootstrap dropdown hover documentation:

http://twitter.github.com/bootstrap/javascript.html#dropdowns

http://twitter.github.com/bootstrap/examples/hero.html

A workaround to this that I have implemented in JS, without having to touch the original code base, is to disable the .on() event handler on the touchstart.dropdown.data-api element.

Therefore add the following line to your code source:
$(document).off('touchstart.dropdown.data-api');

Until Twitter Bootstrap releases a fix for this, the code will remain in my code base for now…

For more information, see https://github.com/twitter/bootstrap/issues/5678

Peter Tran

View Comments

Share
Published by
Peter Tran

Recent Posts

Kubernetes Resources to Learn From

I have been fortunate in working a lot more with Kubernetes lately over the last few months so I've been…

1 year ago

WordPress Development using Docker

Building my portfolio site, I thought I'd show you how I set up my Wordpress development using Docker. Given the…

1 year ago

Blank images in Puppeteer screenshots solved!

Frustrated with getting blank images in Puppeteer Chrome screenshots, recently I was in a situation where I needed to migrate…

1 year ago

Plans Moving Forward – The Revamped Web and I

It has been six year since my last major revamp/redesign of my current petertran.com.au portfolio site. So what are my…

1 year ago

Bad owner or permissions on .ssh/config

This article helps to solve a Bad owner or permissions on .ssh/config issue occurring on a Windows 10 machine when…

1 year ago

Accept payments easily and effortlessly with Pin Payments integration

Only a few lines of code required is to implement a payment system, thanks to inline Pin Payments integration. Accepting…

6 years ago