Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

164
Vistas
php include expression prevents FullCalendar from rendering

I am dealing with 2 php files which are tabs.php and timetable.php. tabs.php acts as a navbar and directs the user to many pages including timetable.php. Whereas timetable.php has a FullCalendar that works perfectly. The way I direct the user from tabs.php to timetable.php is as follows:

<li><button class="tablink" onclick="openPage('Timetable', this)"id="defaultOpen4">Timetable</button></li>
<div id="Timetable" class="tabcontent">
  <?php include("timetable.php"); ?>
</div>

The script for FullCalendar is as follows:

<script>
    $(document).ready(function() {
      $('#calendar').fullCalendar({
        editable: false, //Prevents user from moving around events
        header: {
          left: 'prev, next today',
          center: 'title',
          right: 'month, agendaWeek, agendaDay'
        },
        events: function(start, end, timezone, callback) {
          $.ajax({
            url: 'loadEventsStudent.php',
            dataType: 'json',
            data: {},
            success: function(data) {
              var events = [];

              for (var i = 0; i < data.length; i++) {
                events.push({
                  title: data[i]['class'],
                  start: data[i]['start_event'],
                  end: data[i]['end_event'],
                });
              }
              //adding the callback
              callback(events);
            }
          });
        }
      });
    });
  </script>

The issue is that when I go to the timetable page, only the buttons of the calendar are visible. Once I click any of these buttons, the calendar then gets rendered. The script for the FullCalendar works perfectly fine as I tried running it on another file which makes me think that the include expression is causing this issue. When I try to inspect the Network tab of my browser, I noticed that once I open the timetable page, nothing happens, but once I click on any of the calendars' buttons, the loadEventsStudent.php file (stores data from a database) appears and then the calendar gets rendered. Is there a way to make the calendar render without having to change the way both files are connected?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This is because include() is a PHP function and the HTML code for your calendar is already loaded to the browser.

The quick fix I would suggest is to trigger a click on the calendar buttons when you are viewing the page, so it can load the calendar events when your are visiting the calendar tab.

$( document ).ready(function() {

   // Your code for the calendar comes here

   $("#defaultOpen4").on("click", function() {
     $( ".class-of-the-calendar-button" ).trigger( "click" );
   });
});
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda