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

408
Vistas
FullCalendar - Changing hidden days with jQuery

I'm filtering my calendar, I change the start and end date, status of my events, and other stuffs. I do that with:

 $("body").on("click", "#btnFiltrar", function() {
    fechaIni = $("#fechaIni").val();
    fechaFin = $("#fechaFin").val();
    cp = $("#txtCP").val();

    var events = {
        url: "./php/xxxxxxxx.php",
        type: "POST",
        data: {
            fechaIni:     fechaIni,
            fechaFin:     fechaFin,
            cp:           cp,
            provincia:    provincia,
            ...
          }
    }

    $("#calendar").fullCalendar("removeEventSource", events);
    $("#calendar").fullCalendar("addEventSource", events);
    $("#calendar").fullCalendar("refetchEvents");
});

It works fine. But when I want to change the variable hiddenDays dynamically, I can't make it work! I add to my code this: (By default this variables are global)

var dias = ["0","1","2","3","4","5","6"];
var ocultarDias = []; // is empty because it shows all days

// inside click button
diasSeleccionados = $("#selDias").val(); // returns array eg: ["1","2","3","4","5"]
ocultarDias = $(dias).not(diasSeleccionados).get(); // compare 2 arrays and get the difference

So, with that and the call fullcalendar with the attribute:

function llenarCalendario() {
     $("#calendar").fullCalendar({
        lang: 'es',
        firstDay: 1,
        hiddenDays: ocultarDias,
        ...
     });
}

I miss something? I want to do this without reload the page, just call again the function or, as the function on click button, refetchEvents or something like that. Is possible?

about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

You can recreate the calendar and add the events, which you have already have, again with the following method.

function reloadCalendar(){
    //Get all events in a array
    var events = $("#calendar").fullCalendar( 'getEventSources' ); 

    $("#calendar").fullCalendar( 'destroy' ); // Destroy the calendar
    $("#calendar").fullCalendar({ //Recreate the calendar with the hidden days
        hiddenDays: [ 2, 4 ]
    });

    //With JavaScript
    events.forEach(function(event) { //Restore all events
        $("#calendar").fullCalendar( 'addEventSource', event);
    });

    //With jQuery
    var jEvents =  $.makeArray(events);
    $(jEvents).each(function( i ) {
       $("#calendar").fullCalendar( 'addEventSource', events[i]);
    });
}

Now you simply can call the method. I hope it was helpful.

about 4 years ago · Santiago Trujillo Denunciar

0

You have to use it with optionmethod in order to set new options for your calendar

https://fullcalendar.io/docs/utilities/dynamic_options/

function llenarCalendario() {
     $("#calendar").fullCalendar('option',{
        lang: 'es',
        firstDay: 1,
        hiddenDays: ocultarDias,
        ...
     });
}
about 4 years ago · Santiago Trujillo Denunciar

0

var newhiddendays = [0, 6];         // show Mon-Fr (hide Sat/Sun)

$('#calendar').fullCalendar('option', 'hiddenDays', newhiddendays);
about 4 years ago · Santiago Trujillo 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