dongzeao5047 2014-08-12 09:37
浏览 78
已采纳

Bootstrap下拉列表直接在我的手机上关闭,仅在我自己的网站上

I'm working on a responsive website. We are building this within the Yii framework and within an already existing (self built) multi-webshop platform. I'm trying to implement a dropdown menu using Bootstrap.

I used the code from the Bootstrap website: http://getbootstrap.com/components/#navbar

The code is inside a div with a class name of "main-wrapper"

I only load the following js files: jQuery, bootstrap-dropdown and bootstrap-collapase (My problem also occured when I loaded everything)

The problem: Now comes the problem. When I test it on my browser it works fine, but when I use my phone and I click the dropdown it closes it directly. Feels like it presses the button twice. If I keep it pressed for about a second or 2 it will stay open as intented. My phones is an samsung Galaxy S3 (android 4.3). I tested it on other phones (including a S3 mini, no co-worker seem to have a galaxy S3) and it all works fine. So I figured some sensor inside my phone is just broken, but when I go to the bootstrap website itself it does work (same code I use on my website).

Maybe someone reconizes this problem and I simply missed something, but this one is rather hard to debug. I already limited the code to the absolute minumum.

NOTE: Just to make clear. It closes instantly again when just opening the dropdown menu without clicking anywhere else.

My Code (This is all the code, I removed everything else. Clearly there are some Yii files being loaded, but no other JS/Css files)

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title><?= CHtml::encode($this->pageTitle); ?></title>
        <meta name="description" content="<?= CHtml::encode($this->pageDescription); ?>" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="http://local.bedruktet-shirts.com/themes/bedruktet-shirts.com/bootstrap/css/bootstrap.css" rel="stylesheet">
   </head>
   <body>   
      <div class="main-wrapper">   
      <!-- navbar-fixed-top -->
      <nav class="navbar navbar-default" role="navigation">
          <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </button>
              <a class="navbar-brand" href="#">Brand</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
              <ul class="nav navbar-nav">
                <li class="active"><a href="#">Link</a></li>
                <li><a href="#">Link</a></li>
                <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>
                  <ul class="dropdown-menu" role="menu">
                    <li><a href="#">Action</a></li>
                    <li><a href="#">Another action</a></li>
                    <li><a href="#">Something else here</a></li>
                    <li class="divider"></li>
                    <li><a href="#">Separated link</a></li>
                    <li class="divider"></li>
                    <li><a href="#">One more separated link</a></li>
                  </ul>
                </li>
              </ul>
              <form class="navbar-form navbar-left" role="search">
                <div class="form-group">
                  <input type="text" class="form-control" placeholder="Search">
                </div>
                <button type="submit" class="btn btn-default">Submit</button>
              </form>
              <ul class="nav navbar-nav navbar-right">
                <li><a href="#">Link</a></li>
                <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>
                  <ul class="dropdown-menu" role="menu">
                    <li><a href="#">Action</a></li>
                    <li><a href="#">Another action</a></li>
                    <li><a href="#">Something else here</a></li>
                    <li class="divider"></li>
                    <li><a href="#">Separated link</a></li>
                  </ul>
                </li>
              </ul>
            </div><!-- /.navbar-collapse -->
          </div><!-- /.container-fluid -->
        </nav>
    </div>
    <script src="http://local.bedruktet-shirts.com/themes/bedruktet-shirts.com/bootstrap/js/jquery.js" type="text/javascript"></script> 
    <script src="http://local.bedruktet-shirts.com/themes/bedruktet-shirts.com/bootstrap/js/bootstrap-dropdown.js" type="text/javascript"></script>
    <script src="http://local.bedruktet-shirts.com/themes/bedruktet-shirts.com/bootstrap/js/bootstrap-collapse.js" type="text/javascript"></script>
  </body>
</html>
  • 写回答

1条回答 默认 最新

  • dongmao4486 2014-09-01 10:11
    关注

    I "solved" my own problem...I upgraded bootstrap. Yes...that was all. Someone added bootstrap and I asked him if it was the newest version. So I assumed this was true. However I had a second problem that did not work on a mobile device. So I figure to check the version number.

    I added the newest version of bootstrap and everything 'magically' worked. Not going to delete this question and hide my stupidity. Keeping it as a reminder to others to check the version if they happen to come to this question.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 矩阵加法的规则是两个矩阵中对应位置的数的绝对值进行加和
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀