Drop-Down Menu not working on mobile devices

前端 未结 7 1719
广开言路
广开言路 2020-12-29 08:40

The most recent version of twitter bootstrap (2.3.2) does seem to have a problem with drop down menus on mobile devices.

When you click on a drop-down menu item afte

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-29 08:47

    None of the usual answers seemed to fix our problem on Android. We tried the accepted answer here and a few javascript hacks as well: Bootstrap Collapsed Menu Links Not Working on Mobile Devices and http://alittlecode.com/fix-twitter-bootstraps-dropdown-menus-in-touch-screens/

    Ultimately we discovered where the close was occurring and conditionally called clearMenus() only if the links parent or grand parent did not have dropdown-submenu class

    $(document)
    .on('click.dropdown.data-api', function (e) {
    
        //fix start        
        var $parent = $(e.target).parent()
        var $grandparent = $parent.parent()
    
        if (!$parent.hasClass('dropdown-submenu') && !$grandparent.hasClass('dropdown-submenu')) {        
            clearMenus()
        }
    
        //clearMenus
    
        //end fix
    })
    .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
    .on('click.dropdown.data-api'  , toggle, Dropdown.prototype.toggle)
    .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
    
    }(window.jQuery);
    

    Hope that helps!

提交回复
热议问题