I'm making a religious calendar for a project that shows different events for all major religions. I'm using full calendar, and I have a "religion key" at the top of the calendar, and I want to make it so that when I click, for example, Jewish, it will hide all religious events/holidays on the calendar that don't pertain to the Jewish faith. I'm having some trouble. My thinking was that I would set the ".fc-event" class in css to display:none" and then have a class called .show that would be display:block. and toggle that class / remove that class when the user clicks the menu item that pertains to the holiday. Is there a better / easier way to do this? would love some guidance/tips/help :) thank you.
Here is my code for the calendar js (using made up dates obviously):
events: [
{
title: 'xmas',
start: '2017-03-19',
className: 'catholic show',
description: 'blablablablabla'
},
{
title: 'Hanukkah',
start: '2017-03-19',
className: 'jewish show',
description: 'blablablabla'
},
{
title: 'Hindu Holiday',
start: '2017-03-24',
end: '2017-03-27',
className: 'hindu show',
description: 'blablablabla'
}
]
});
$('.calendar-nav a').each(function() {
$(this).on('click', function(e) {
e.preventDefault();
var x = $(this).attr('rel');
$('.fc-event-container').each(function() {
$(this).removeClass('show');
if($(this).hasClass(x)) {
$(this).addClass('show');
}
});
})
});
$('.show-all a').on('click', function() {
$('.fc-event-container').each(function() {
if(!$(this).hasClass('show')) {
$(this).toggleClass('show');
}
});
});
});
And the php code for the calendar and calendar-key:
<nav class="calendar-nav">
<ul class="menu">
<li class="christianity-text"><a href="#" rel="christian">><img src="/images/calendar/christianity.png" />CHRISTIAN</a>
<ul class="sub-menu">
<li><a href="#">Catholic</a></li>
<li><a href="#">Protestant</a></li>
<li><a href="#">Coptic</a></li>
<li><a href="#">Mormon</a></li>
<li><a href="#">Neo</a></li>
<li><a href="#">Anglican</a></li>
<li><a href="#">Celtic</a></li>
<li><a href="#">Jehova's Witness</a></li>
</ul>
</li>
<li class="buddhist-text"><a href="#" rel="buddhist"><img src="/images/calendar/buddhism.png" />BUDDHIST</a></li>
<li class="hindu-text"><a href="#" rel="hindu"><img src="/images/calendar/hindu.png" />HINDU</a></li>
<li class="jewish-text"><a href="#" rel="jewish"><img src="/images/calendar/jewish.png" />JEWISH</a></li>
<li class="islam-text"><a href="#" rel="islam"><img src="/images/calendar/islam.png" />ISLAM</a></li>
<li class="sikh-text"><a href="#" rel="sikh"><img src="/images/calendar/sikh.png" />SIKH</a></li>
<li class="pagan-text"><a href="#" rel="pagan"><img src="/images/calendar/pagan.png" />PAGAN</a></li>
<li class="wiccan-text"><a href="#" rel="wiccan"><img src="/images/calendar/wiccan.png" />WICCAN</a></li>
<li class="other-text"><a href="#" rel="other"><img src="/images/calendar/other.png" />OTHER</a></li>
<li class="all-text"><a href="#" rel="all">ALL</a></li>
</ul>
</nav>
<div id='calendar'></div>