Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

406
Views
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 answers
Answer question

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 Report

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 Report

0

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

$('#calendar').fullCalendar('option', 'hiddenDays', newhiddendays);
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!