0

I'm having a problem with date picker. Search some answers too but doesn't seem to help, here's my code:

<link rel="stylesheet" type="text/css" href="../css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="../datepicker/css/datepicker.css" />

<div class='input-group date' id='datetimepicker1'>
    <input type='text' class="form-control" placeholder="Date"/>
    <span class="input-group-addon">
        <span class="glyphicon glyphicon-calendar"></span>
    </span>
</div>

<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../datepicker/js/bootstrap-datepicker.js"></script>

<script type="text/javascript">
    $(function () {
        $('#datetimepicker1').datepicker();
    });
</script>
Audix
  • 47
  • 2
  • 8

2 Answers2

0

The #datetimepicker1 should be in the input, not in the div. So try this:

<div class='input-group date'>
    <input type='text' class="form-control" placeholder="Date" id='datetimepicker1' />
    <span class="input-group-addon">
        <span class="glyphicon glyphicon-calendar"></span>
    </span>
</div>
Tomatrox
  • 693
  • 7
  • 14
  • After further Googling, I found out it has something to do with modal and datepicker z-axis. Will update later. – Audix Feb 01 '14 at 01:41
0

Please change jQuery selector to $('**.input-group.date**').datepicker();

The DIV is necesaary for datepicker to be initiated. Please refer to http://jsbin.com/lerojivu/1/edit


The variant zIndex in source code

place: function ()...

Due to using the modal z-index property is zero. It can be amended listed below.

var parentZIndexes = this.element.parents().map(function() {
                           return parseInt($(this).css('z-index')) || 0;
                      });
var zIndex = Math.max.apply(Math, Array.prototype.slice.apply(parentZIndexes)) + 10;
Cliff Liu
  • 186
  • 1
  • 6