Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

407
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

0

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

$('#calendar').fullCalendar('option', 'hiddenDays', newhiddendays);
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda