Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fullcalendar next and prev

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

like image 763
Faiyet Avatar asked Feb 22 '11 18:02

Faiyet


2 Answers

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.

like image 95
justkt Avatar answered Sep 28 '22 16:09

justkt


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');
});
like image 45
la_antorcha Avatar answered Sep 28 '22 14:09

la_antorcha