I'm currently working on a fullcalendar (v3) project; I'm new to this library and also a noob in Javascript, just know basic stuff.
First at all: to access my calendar I implemented a login session (so when u access the calendar the page has a $_SESSION['user'], where user is saved as 'nomeUtente') and my calendar fecth events from a database with this details
nomeUtente (in this case 'dip7') it's a variable saved that coincide with the $_SESSION['nomeUtente'] at the moment someone is logged in and save a new Events
I also have two checkboxes (orePersonali and Assenze) (the actual $_SESSION['nomeUtente'] is dip5)
This is their code:
<input type="checkbox" id="OP" name="calendario" value="OP" checked>
<input type="checkbox" id="assenze" name="calendario" value="assenze">
At the moment both of the checkboxes hide and show every events, throught this function:
$('#calendar').fullCalendar('render');
function eventsHidden(context){
let x = $(".fc-event-container");
if (context.prop("checked") ) {
x.css({
visibility: "visible"
});
} else {
x.css({
visibility: "hidden"
});
}
};
function eventsHiddenA(context){
let x = $(".fc-event-container");
if (context.prop("checked")) {
x.css({
visibility: "visible"
});
} else {
x.css({
visibility: "hidden"
});
}
};
$("#OP").on("change", function () {
eventsHidden($(this))
});
$("#assenze").on("change", function () {
eventsHiddenA($(this))
});
Recalled in the fullcalendar section by dayRender:
dayRender: function(view, element,render, cell) {
render = !render ? (
false
) : true
setTimeout(() => {
eventsHidden($("#OP"))
eventsHiddenA($("#assenze"))
render = false
}, 0)
}
Want i would like to do is: when "Assenze" is unchecked to hide all events that have a 'nomeUtente' != from $_SESSION['nomeUtente'], basically to the user who's logged at the moment (in the case of the previusly screen 'dip5')