Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rerendering events in fullCalendar after Ajax database update

Tags:

I am trying to have fullCalendar reflect changes made to a database via AJAX. The problem is that it won't update the calendar on screen after a successful AJAX call.

$.ajax({     type: "POST",     url: "eventEditXHR.php",     data: {        //the data     },     success: function(text) {       $("#calendar").fullCalendar("refetchEvents");     }.... 

I'm I using the wrong method? What would be the best way to accomplish this without having to reload the whole page? Thanks for any input!

like image 448
Guy Avatar asked Jan 18 '14 12:01

Guy


People also ask

How do I set events in fullCalendar?

Here is an example of how to specify an array of events: var calendar = new Calendar(calendarEl, { events: [ { title : 'event1', start : '2010-01-01' }, { title : 'event2', start : '2010-01-05', end : '2010-01-07' }, { title : 'event3', start : '2010-01-09T12:30:00', allDay : false // will make the time show } ] });

How do I re render fullCalendar?

fullCalendar('render'); If you don't actually need to render the table, but just rerender the events again, you could use the 'rerenderEvents' method: $('#calendar'). fullCalendar('rerenderEvents');

How do I hide time in fullCalendar?

This option is available from v2. 4.0 see fullcalendar.io/docs/text/displayEventTime - You need to set it as option of fullCalendar and it affects all events. Or use CSS . fc-time{ display : none; } .

How do I start and end date in fullCalendar?

We can get start date by getView event with intervalStart. We can get end date by getView event with intervalEnd. var month = $('#calendar'). fullCalendar('getView').


1 Answers

There are several ways. Some less elegant.

1. If you are using FullCalendar to grab json events:

$('#calendar').fullCalendar({ events: "json-events.php",    }); 

Just do:

$('#calendar').fullCalendar( 'refetchEvents' ); 

If you want outside method to fetch events you could do. Not elegant but will work

$('#calendar').fullCalendar( 'removeEventSource', source ) $('#calendar').fullCalendar( 'addEventSource', source ) 
like image 128
Igor S. Avatar answered Nov 09 '22 23:11

Igor S.