我的引导程序datetimepicker
存在严重问题,这是jsfiddle:
<br/>
<!-- padding for jsfiddle -->
<div class="row">
<div class="col-md-12">
<h6>datetimepicker1</h6>
<div class="form-group">
<div class="input-group date" id="datetimepicker1">
<input type="text" class="form-control" > <span class="input-group-addon"><span class="glyphicon-calendar glyphicon"></span></span>
</div>
</div>
</div>
</div>
问题在于,当我在移动设备上打开我的网站时,当我关注输入字段时触发了移动键盘,所以我需要的是只有datepicker
显示没有键盘。因此,我使用readonly
或disabled
,但问题是,当我使用其中一个时,引导程序datetimepicker
不起作用。
http://jsfiddle.net/faissal_aboullait/kx0e5wmq/1/
答案 0 :(得分:48)
如果您仍在寻找解决方案,请查看该代码段。这正是我在评论中建议的,你只需要用
调用datetimepickerignoreReadonly: true
那就是它。
$(function () {
$('#datetimepicker').datetimepicker({
ignoreReadonly: true
});
});
&#13;
.container {
margin-top: 80px;
}
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.min.css" rel="stylesheet"/>
<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.4/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/js/bootstrap-datetimepicker.min.js"></script>
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class='col-sm-6 col-sm-offset-3'>
<div class="form-group">
<div class='input-group date' id='datetimepicker'>
<input type='text' class="form-control" readonly />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
&#13;
使用图标选择日期而不是文本字段。文本字段是只读的。
答案 1 :(得分:1)
put 语句中的子句 readonly="yes" 是可行的, 不包括实际需要的库,如下所示
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.js">
</script>
答案 2 :(得分:0)
这对我有用:
.bootstrap-datetimepicker-widget.dropdown-menu {
width: 100%;
max-width: calc(100%) !important;
}
答案 3 :(得分:0)
以下条款 是可行的, 如果它不起作用,则仅表示未包含所需的库,如下所示
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.js">
</script>