单击导航栏链接时不显示模态

时间:2015-06-14 12:10:26

标签: asp.net twitter-bootstrap

我目前正在尝试实施一种在点击导航栏中的链接时显示的模式。我知道已经提出了类似的问题,但没有一个解决方案能够奏效。

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/ic_dashboard_pressed"
          android:state_pressed="true" />
    <item android:drawable="@drawable/ic_dashboard_selected"
          android:state_selected="true" />
    <item android:drawable="@drawable/ic_dashboard_normal" />
</selector>

我使用的脚本是:bootstrap.js,bootstrap.min.js,jquery-2.1.4.min.js P.S:我已经尝试了href =&#34;#&#34;在链接中。 谢谢你的帮助!

1 个答案:

答案 0 :(得分:1)

试试这个: (我只插入了正确的依赖项,你的代码正在运行)

<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

<nav class="navbar navbar-default">
  <div class="container-fluid">
  <div class="navbar-header">
  <a class="navbar-brand" href="#">My Tool</a>
</div>

  <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
    <ul class="nav navbar-nav">
      <li><a href="#">FAQ</a></li>
      <li><a href="#">About</a></li>
      <li><a data-toggle="modal" data-target="#myModal">Add Something</a></li>
    </ul>
  </div>
 </div>
</nav>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
 <div class="modal-dialog">
 <div class="modal-content">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <h4 class="modal-title" id="myModalLabel">Modal title</h4>
  </div>
  <div class="modal-body">
    ...
  </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    <button type="button" class="btn btn-primary">Save changes</button>
  </div>
</div>