javascript FullCalendar - 上一个/下一个
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20431712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
FullCalendar - prev / next
提问by user789122
I'm using Fullcalendar
to display some events form json. That is all fine and I see them.
我正在使用Fullcalendar
以 json 形式显示一些事件。一切都很好,我看到了。
What I'm looking at doing though, is to reload the events based on the month.
不过,我正在做的是根据月份重新加载事件。
So, I thought I could get the date based on what month I'm on from clicking Prev
or Next
.
所以,我想我可以根据我点击Prev
或的月份来获得日期Next
。
I have the following is http://jsfiddle.net/6wE8v/408/
我有以下是http://jsfiddle.net/6wE8v/408/
There is a strange occurrence when clicking back and forth getting incorrect months.
来回点击得到错误的月份时会出现奇怪的情况。
This is slightly worrying as the data needs to be accurate.
这有点令人担忧,因为数据需要准确。
Does anyone have any ideas why this could be happening?
有谁知道为什么会发生这种情况?
Thanks
谢谢
回答by Kevin
Your handler is being executed before the plugin has changed the month.
您的处理程序正在插件更改月份之前执行。
One way to solve this is to manually trigger the next/prev events yourself.
解决此问题的一种方法是自己手动触发下一个/上一个事件。
http://jsfiddle.net/6wE8v/408/
http://jsfiddle.net/6wE8v/408/
$('#calendar').fullCalendar(
{
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
});
$('.fc-button-prev span').click(function(){
var date1 = $('#calendar').fullCalendar('prev').fullCalendar( 'getDate' );
alert('prev ' + date1.getMonth());
return false;
});
$('.fc-button-next span').click(function(){
var date1 = $('#calendar').fullCalendar('next').fullCalendar( 'getDate' );
alert('next ' + date1.getMonth());
return false;
});