Jquery完整日历禁用过去日期
如何在fullcalendar中禁用过去的日期Jquery完整日历禁用过去日期,jquery,fullcalendar,Jquery,Fullcalendar,如何在fullcalendar中禁用过去的日期 $('#calendar').fullCalendar({ editable: false, selectable: true, eventLimit: true, views: { agenda: { eventLimit: 1 // adjust to 6 only for agendaWeek/agendaDay } }, select: functio
$('#calendar').fullCalendar({
editable: false,
selectable: true,
eventLimit: true,
views: {
agenda: {
eventLimit: 1 // adjust to 6 only for agendaWeek/agendaDay
}
},
select: function(start, end, allDay) {
var check = $.fullCalendar.formatDate(start, 'yyyy-MM-dd');
var today = $.fullCalendar.formatDate(new Date(), 'yyyy-MM-dd');
if (check >= today) {
$('.addClass').addClass('sticky');
}
}
});
这是我的代码工作良好,我可以选择从新的日期只有addClass也工作良好。但是如果我选择下个月的日期,addClass将不工作。注意:我只想通过使用选择选项来执行此操作,而不是在白天单击。请尝试以下操作:
select: function(start, end, allDay) {
if(start.isBefore(moment())) {
alert('Event is start in the past!');
} else {
// event ok
}
}
在该方法中,检查开始日期,即是否为过去日期
我建议您阅读moment.js libary,fullcalendar使用的是什么
$('#calendar').fullCalendar({
editable: false,
selectable: true,
eventLimit: true,
views: {
agenda: {
eventLimit: 1 // adjust to 6 only for agendaWeek/agendaDay
}
},
select: function(start, end, allDay) {
var check = $.fullCalendar.formatDate(start, 'yyyy-MM-dd');
var today = $.fullCalendar.formatDate(new Date(), 'yyyy-MM-dd');
if (check >= today) {
$('.addClass').addClass('sticky');
}
}
});
我希望它能帮助您。使用$datepicker.datepicker{minDate:0};禁用上个月和上个日期 例如:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script>
$(document).ready(function() {
$( "#date" ).datepicker({ minDate: 0});
});
</script>
</head>
<body>
<input id="date" />
</body>
</html>
希望它能帮助你
$(function() {
$('#calendar').fullCalendar({
defaultView: 'month',
header: {
left: 'prev,next',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
selectable: true,
selectAllow: function(selectInfo) {
return moment().diff(selectInfo.start) <= 0
}
})
})
您可以查看此链接:嘿!您的目标是禁用过去的选择?@LakiGeri是的,我想禁用过去的日期和月份请检查您的答案