【发布时间】:2015-03-14 00:51:37
【问题描述】:
我在页面上有一个按钮,该按钮调用具有日期选择器的模式。
如果这个按钮在顶部(我不必滚动页面来点击),模式打开并且日期选择器正确显示。
但是如果这个按钮在页面的下方(所以我必须滚动页面才能点击),模式打开并且日期选择器显示不正确。 (不确定滚动是否有关系)
这是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插件一样。 -
@TimLewis :它不会出现在下面。它不在位置上,否则会有一个带有日期选择器框的箭头,就像工具提示一样。
-
嗯......好吧,我似乎无法让你的小提琴工作...... 2个控制台错误:
moment is not defined和$(...).datetimepicker() is not a function。 -
@TimLewis : 我添加了 momenjs 文件,但我不知道为什么我得到
datetimepicker()is not a function on the fiddle,即使添加了它的 js 文件。
标签: javascript css html twitter-bootstrap datepicker