Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 229
bey23 Avatar asked Sep 17 '25 20:09

bey23


1 Answers

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

$('#calendar').fullCalendar('option', 'hiddenDays', newhiddendays);
like image 64
jibboo Avatar answered Sep 20 '25 11:09

jibboo