I'm using Fullcalendar
to display some events form json. That is all fine and I see them.
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
.
I have the following is /
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
I'm using Fullcalendar
to display some events form json. That is all fine and I see them.
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
.
I have the following is http://jsfiddle/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
Share Improve this question edited Dec 7, 2013 at 0:34 mcuadros 4,1443 gold badges39 silver badges45 bronze badges asked Dec 6, 2013 at 19:08 user789122user789122 4805 gold badges12 silver badges25 bronze badges 1- This link might be helpful. – Jhecht Commented Dec 17, 2016 at 5:54
1 Answer
Reset to default 1Your 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/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;
});