从 daterangepicker 禁用或删除 mintues 下拉菜单
Posted
技术标签:
【中文标题】从 daterangepicker 禁用或删除 mintues 下拉菜单【英文标题】:Disable or remove mintues dropdown from daterangepicker 【发布时间】:2020-07-23 13:59:52 【问题描述】:我想禁用 daterangepicker 的未来时间,我已经尝试过
"maxDate": moment().utc().startOf('hour'),
但这只会禁用未来的日期而不是小时。
另外,我如何禁用分钟下拉菜单或删除它 daterangepicker 因为我只想保留小时下拉菜单。
下面是我正在使用的。
$('#demo').daterangepicker(
"showISOWeekNumbers": true,
"timePicker": true,
"showDropdowns": true,
"timePicker24Hour": true,
"autoUpdateInput": true,
"format" : 'HH:00',
"maxDate": moment().utc().startOf('hour'),
"dateLimit" :
'days': 7
,
"maxSpan":
"days": 7
,
"locale":
"cancelLabel": 'Clear',
"format": "DD/MM/YYYY @ HH:00",
"separator": " - ",
"applyLabel": "Apply",
"cancelLabel": "Cancel",
"fromLabel": "Start",
"toLabel": "End",
"weekLabel": "W",
"daysOfWeek": [
"Su",
"Mo",
"Tu",
"We",
"Th",
"Fr",
"Sa"
],
"monthNames": [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
],
"firstDay": 1
,
"linkedCalendars": true,
"startDate": 1
);
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/bootstrap/3/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" id="demo" name="datefilter" value="" />
<script type="text/javascript" src="//cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.js"></script>
【问题讨论】:
【参考方案1】:我可以通过添加我的 js 代码来默认并将分钟下拉菜单修复为 00
"timePickerIncrement" : 60,
【讨论】:
以上是关于从 daterangepicker 禁用或删除 mintues 下拉菜单的主要内容,如果未能解决你的问题,请参考以下文章
如何在 daterangepicker JS 和 Laravel 中禁用占用的日期
DateRangePicker显示错误的日期或未应用所选日期