jqueryfullcalendar
我正在尝试集成jquery完整日历插件。。我想禁用过去的选择日期。。因此,我只能选择从当前日期开始的日期。怎么可能呢?如何筛选日期并指定条件。我不熟悉jqueryjqueryfullcalendar,jquery,jquery-plugins,fullcalendar,Jquery,Jquery Plugins,Fullcalendar,我正在尝试集成jquery完整日历插件。。我想禁用过去的选择日期。。因此,我只能选择从当前日期开始的日期。怎么可能呢?如何筛选日期并指定条件。我不熟悉jquery $(document).ready(function() { var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); var calendar = $
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
selectable: true,
selectHelper: true,
select: function(start, end, allDay) {
var title = prompt('Event Title:');
if (title) {
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end,
allDay: allDay
},
true // make the event "stick"
);
}
calendar.fullCalendar('unselect');
},
editable: true,
});
});
在select方法中,会向您提供所选的开始和结束日期,在该方法中,您会在
date
变量中获得当前日期。因此,只需比较它们,如果小于日期
,则处理错误
select: function(start, end, allDay) {
if(start < date)
{
// Do whatever you want here.
alert('Cannot select past dates.');
return;
}
var title = prompt('Event Title:');
if (title) {
calendar.fullCalendar('renderEvent', {
title: title,
start: start,
end: end,
allDay: allDay
},
true // make the event "stick"
);
}
calendar.fullCalendar('unselect');
},
选择:功能(开始、结束、全天){
如果(开始<日期)
{
//在这里你想干什么就干什么。
警报('无法选择过去的日期');
返回;
}
var title=prompt('事件标题:');
如果(标题){
日历。完整日历('renderEvent'{
标题:标题,,
开始:开始,
完:完,,
全天
},
true//使事件“持续”
);
}
日历。完整日历(“取消选择”);
},
注意:关于Brandon的答案,如果单击当前日期,也会出现弹出窗口。您还需要检查用户是否单击了今天的日期:
if (start < date && start.getDate() != date.getDate() ) {
alert('Cannot select past dates.');
return;
}
if(start
如何将月份名称设置为Shortmonth name,如JUL.当前,当我给出start.getMonth()并发出警报时,它会将月份显示为整数。即7月7日。我想把它显示为JUL@user,你应该问另一个问题,因为这与你最初问的问题无关。但是,fullCalendar有一个Monthnameshort数组(),所以只要执行类似于Monthnameshort[start.getMonth()]
的操作,在上面的代码中,如果我尝试发出警报(Monthnameshort[start.getMonth()]);那么我会把这个月定为七月吗??我是jquery的新手。。因此,这对我来说是一个学习阶段:)我需要在上面的提示消息之后显示它。请help@user,您实际上已经发布了另一个问题。我建议将这些评论转移到另一个问题上,以便让更多的人看到。是否可以从完整日历中删除过去的日期和下个月的日期。。因此,对于当前月份,它应该只显示当前日期和日期。。??