我的日期时间选择器适用于第一次点击,但如果我再次在输入字段中再次点击它会显示带有日期字段的选择器。我怎样才能做到这一点?任何帮助将不胜感激。
这是第一次点击的图像(预期行为)
这是第二次点击时的图像(预期的行为就像第一次一样)
我的代码在
下面<div class='input-group' id='dpRM'>
<input type='text' class="form-control form-control-1 form-input input-sm fromq" placeholder="Enter Month and year" />
<span class="input-group-addon">
<span class="fa fa-calendar"></span>
</span>
</div>
<script type="text/javascript">
$(function() {
$('#dpRM').datetimepicker({
format: "MMMM YYYY",
viewMode: "years",
//minViewMode: 0,
toolbarPlacement: "top",
allowInputToggle: true,
icons: {
time: 'fa fa-time',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-screenshot',
clear: 'fa fa-trash',
close: 'fa fa-remove'
}
});
});
</script>
提前致谢
答案 0 :(得分:3)
尝试以下
$('#dpRM').datetimepicker({
viewMode : 'months',
format : 'MM/YYYY',
toolbarPlacement: "top",
allowInputToggle: true,
icons: {
time: 'fa fa-time',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-screenshot',
clear: 'fa fa-trash',
close: 'fa fa-remove'
}
});
$("#dpRM").on("dp.show", function(e) {
$(e.target).data("DateTimePicker").viewMode("months");
});
REF :: GitHub