javascript - FullCalendar.io - 如何使用营业时间来防止日期点击某些时间
问题描述
我正在使用https://fullcalendar.io,特别是 dateClick 函数如下
dateClick: function(info) {
//alert('clicked ' + info.dateStr);
calendar.changeView('timeGridDay', info.dateStr);
console.log(info);
if (info.view.type == 'timeGridDay') {
date = info.dateStr;
var modal = $('#add-event-modal');
modal.modal('show');
$(modal).find('input[name=parade_start]').val(info.dateStr.substring(0, 10) + ' ' + info.dateStr.substring(11, 19));
}
},
我也在使用上午 9 点到下午 5 点之间的营业时间。目前,用户可以在视图中的任何时间单击以弹出模式,但我希望仅在他们单击营业时间时才打开模式。
请告知 - 不确定这是否可能
谢谢
解决方案
最好使用选择回调(而不是 dateClick)来检测用户选择。
完成此操作后,您可以将selectConstraint选项设置为“营业时间”,这会自动阻止人们选择规定营业时间以外的时间。
例如:
selectable: true,
select: function(info) {
alert("selected " + info.startStr + " to " + info.endStr);
},
businessHours: {
// days of week. an array of zero-based day of week integers (0=Sunday)
daysOfWeek: [1, 2, 3, 4], // Monday - Thursday
startTime: "10:00", // a start time (10am in this example)
endTime: "18:00" // an end time (6pm in this example)
},
selectConstraint: "businessHours"
推荐阅读
- php - 当用户关闭浏览器/选项卡时自动更改数据库中的状态
- go - 是否可以在运行时更新 zap 记录器的日志级别?
- python - 如何使用 BioPython 识别受体和供体原子?
- reactjs - React-hook-form 输入类型值不起作用
- c++ - 使用 std::async 调用函数时,引用变量的地址不同
- powershell - 在PowerShell中将文件夹重命名为小写
- windows - 我如何解决 wine 中的桌面窗口管理器问题
- c++ - 在这种情况下,我可以将模板类的构造函数保持为私有吗?
- python - 构建 Plotly Dash 时出错(npm run build)
- python - 如何根据我从数值函数创建的新数据集的某个值找到我的数据集的数量