down123321123 2015-09-23 02:01
浏览 618
已采纳

Datetimepicker在上方显示时不起作用

I am facing a problem where my bootstrap datetimepicker cannot work properly when the datetimepicker is shown on the upper side.

Here is a screenshot:

Show on up

I cannot click anything on the datetimepicker when the datetimepicker shown on the upper side

Show on down

When the datetimepicker is shown on the lowers side, I can click and select the datetimepicker and it will work properly.

This is my code:

<script type="text/javascript">

$(function() {
$('#select_year').datepicker({
 format: "yyyy", // Notice the Extra space at the beginning
viewMode: "years", 
minViewMode: "years",
 autoclose: true
});
});
</script>

This is how I display the row:

        <form action="set_holidays.php" method="post" >
    <div class="col-sm-3">
        <label for="field-1"  class="control-label pull-left holiday-vertical"><h4 style='padding-left:10px;'><b>Year</b></h4></label>  
        <div class="col-sm-8"> 
            <div class="input-group date">           
            <input type="text" id="select_year" name="year" class="form-control years" value="$this->year">
              <span class="input-group-btn">
                        <button class="btn btn-default" type="submit">Go</button>
                        <input type='hidden' value='refresh' name='action'>
                    </span>
            </div>
        </div>                        
             </div>                                    
    </form>

This is how i included js and css

<link type="text/css" href="mypath/bootstrap.min.css" rel="stylesheet"/>
<link type="text/css" href="mypath/bootstrap-datetimepicker.min.css" rel="stylesheet"/>
<link type="text/css" href="mypath/datepicker.css" rel="stylesheet"/>

<script type="text/javascript" src="mypath/jquery.min.js"></script>
<script type="text/javascript" src="mypath/bootstrap.min.js"></script>
<script type="text/javascript" src="mypath/bootstrap-datepicker.js"></script>
  • 写回答

1条回答 默认 最新

  • douzhoulei8959 2015-09-23 02:55
    关注

    It is an assumption that you are using the datepicker from http://eternicode.github.io/bootstrap-datepicker which has an option for orientation that could be set as orientation: "top auto" which would keep the calendar's top against the input box.

    See the sinppet

    $(function() {
      $('#select_year').datepicker({
        format: "yyyy", // Notice the Extra space at the beginning
        viewMode: "years",
        minViewMode: "years",
        autoclose: true,
        orientation: "top auto"
      });
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <script src="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
    <link href="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet" />
    
    <form action="set_holidays.php" method="post">
      <div class="col-sm-3">
        <label for="field-1" class="control-label pull-left holiday-vertical">
          <h4 style='padding-left:10px;'><b>Year</b></h4>
        </label>
        <div class="col-sm-8">
          <div class="input-group date">
            <input type="text" id="select_year" name="year" class="form-control years" value="$this->year">
            <span class="input-group-btn">
              <button class="btn btn-default" type="submit">Go</button>
              <input type='hidden' value='refresh' name='action'>
            </span>
          </div>
        </div>
      </div>
    </form>

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

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了