Only yesturday I started to use the jquery fullcarlendar plugin. Now What I am trying to do is on clicking the next or prev buttons I am doing a jquery
$('#element').load('some_url_here')
How exactly do I use the next and previous methods to do something like
$('#calendar').fullCalendar({
prev: function(){
$('#calendar').load("events/findbymonth/"+$('#calendar').fullCalendar('getDate').getMonth());
},
next: function(){
$('#calendar').load("events/findbymonth/"+$('#calendar').fullCalendar('getDate').getMonth());
},
title: "My Title",
events: jsonString,
editable: false,
disableDragging: true
});
All I need for my url is the next month.
Do I have to manually increment the current month for next and decrement for previous?
Is there a "getCurrentMonth()" method which I can call directly?
Something like $('#calendar').load("events/findbymonth/"+$('#calendar').fullCalendar.getCurrentMonth());
Thanks, guys
When the next and previous buttons are clicked, calls are automatically made to the event sources you specify - you don't have to do a manual load. Prev and next are used to programmatically move the calendar as opposed to being used to specify hooks for overriding the default behavior.
FullCalendar sends requests for events as follows: /events/find/?start=1262332800&end=1265011200&_=1263178646
When you click on next and previous, it gets the time since the epoch of the start of the month and the time since the epoch of the end of the month and uses those as parameters for start and end. The _ parameter is unique per call to prevent caching.
According to the documentation you can change the parameter names start
and end
but not the values. To change those values you'd have to modify FullCalendar itself.
Assuming you can change the code that sends your JSON, I'd suggest changing to code that takes seconds since the epoch values as input and return events based on that. If you can't do that, start looking into modifying the FullCalendar source to meet your needs.
I know is late, but if somenone has the same problem this is how you make cutom navigation controls:
$('#btnNext').click(function() {
$('#calendar').fullCalendar('next');
});
$('#btnPrev').click(function() {
$('#calendar').fullCalendar('prev');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With