Modal中的日期和时间选择器以及多个链接不起作用

时间:2017-08-22 20:39:09

标签: jquery twitter-bootstrap bootstrap-modal

我希望能够在文本框中有一个日期和时间选择器,但我无法让它工作,我也可以获得第一个打开的链接,但第二个链接也将打开第一个链接。

有人可以看看我做错了什么吗?

以下是代码示例:

代码主页

<!DOCTYPE html>
<html>
  <head>
    <title>Bootstrap 3 Modal with remote content</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- Bootstrap core CSS -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.1.0/css/bootstrap.css" rel="stylesheet" media="screen">


    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.2/html5shiv.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.2.0/respond.js"></script>
    <![endif]-->
  </head>
  <body>
<a data-toggle="modal" class="btn btn-info" href="remotePage.php?id=123" data-target="#myModal">Link 1</a>
<BR><BR>
<a data-toggle="modal" class="btn btn-info" href="remotePage2.php?id=456" data-target="#myModal">Link 2</a>

<!-- Modal -->
<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><!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.1.0/js/bootstrap.min.js"></script>

    </body>
</html>

远程页面(“remotePage.php”)

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Remote file for Bootstrap Modal</title>  
</head>
<body>
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                 <h4 class="modal-title">Modal title</h4>
            </div>          <!-- /modal-header -->
            <div class="modal-body">
<div id="datetimepicker1" class="input-append date">
     <input data-format="dd/MM/yyyy hh:mm:ss" type="text"></input>
     <span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
</div>          
            <p>Excitavit hic ardor milites per municipia plurima, quae isdem conterminant, dispositos et castella, sed quisque serpentes latius pro viribus repellere moliens, nunc globis confertos, aliquotiens et dispersos multitudine superabatur ingenti.</p>
            </div>          <!-- /modal-body -->
            <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>          <!-- /modal-footer -->

<!-- DATE AND TIME PICKER -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js'></script>
<script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/2708/bootstrap-datetimepicker.min.js'></script>
<script>$(function() {
  $('#datetimepicker1').datetimepicker({});
});
</script>
<!-- DATE AND TIME PICKER -->

</body>
</html>

* REMOTE PAGE 2只是一些随机文本

1 个答案:

答案 0 :(得分:-1)

<script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/2708/bootstrap-datetimepicker.min.js'></script>

将此路径添加到index.php,因为它显示的是datetimepicker不是函数