我有一個頁面上的按鈕調用具有日期選擇器的模式。Bootstrap Datepicker出現在模式不正確的位置
如果此按鈕位於頂部(我不必滾動頁面進行單擊),模式將打開並且datepicker正確顯示。
但是,如果此按鈕在頁面上較低(這樣我必須滾動頁面進行單擊),模式將打開並且datepicker顯示不正確。 (如果滾動有關係,不知道)
這裏是jsfiddle
這裏的圖像顯示問題,日期選擇器應該上方顯示一個提示,但它的股價下跌:
下面的代碼:
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#callModal">Contact</button>
<div class="modal fade" id="callModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<form role="form">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" placeholder="Enter name">
</div>
<div class="form-group">
<label for="contact">Contact</label>
<input type="text" class="form-control" id="contact" placeholder="Your mobile number">
</div>
<div class="row">
<div class='col-sm-6'>
<div class="form-group">
<label for="cal">Date & Time</label>
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" id="cal"/>
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
<script type="text/javascript">
$(function() {
$('#datetimepicker1').datetimepicker();
});
</script>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-danger">Contact </button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
編輯 的的DateTimePicker工具在點擊「聯繫人」按鈕之前,我會滾動頁面的數量,以顯示包含datetimepicker的模式。
我不會說「錯誤」的位置,因爲這是datetimepicker的預期行爲,但是你想要它在上面,而不是在下面,對嗎?目前,我不認爲'orientation'有一個選項,就像'datepicker'插件一樣。 – 2015-01-15 15:28:03
@TimLewis:這不是下面。它的偏離位置,否則就會有一個帶有日期選擇框的箭頭,就像工具提示一樣。 – 2015-01-15 15:42:45
嗯...好吧,我似乎無法讓你的小提琴工作... 2控制檯錯誤:'時刻沒有定義'和'$(...)。datetimepicker()不是一個函數。 – 2015-01-15 15:51:38