Axel
Axel

Reputation: 467

How to render fullCalendar using AJAX

I want to render a calendar with fullCalendar using AJAX. I'm trying it right now but I'm not getting it to work.

EDIT

In the client side I have:

$( document ).on( "click", ".goto", function(e) { 
   e.preventDefault(); 

   var rel = $(this).attr('rel'); 

   $.post('./controller.php',{ page: rel },function(data) {
       $('#ajaxlayer').html(data); 
       $('#calendar').fullCalendar('render'); 
    }); 
}); 

And the PHP returns:

<div id='calendar'></div>

Upvotes: 0

Views: 1006

Answers (1)

Axel
Axel

Reputation: 467

Solved, I changed the JS callback as follows:

$( document ).on( "click", ".goto", function(e) { 
   e.preventDefault(); 

   var rel = $(this).attr('rel'); 

   $.post('./controller.php',{ page: rel },function(data) {
       $('#ajaxlayer').html(data); 
       $('#calendar').fullCalendar({
         header: {
           left: 'prev,next today',
           center: 'title',
           right: 'month,agendaWeek,agendaDay'
         },
         editable: true,
         events: 'eventos.json');
       }); 
  }); 

Upvotes: 1

Related Questions