I was wondering if there was a way in Arshaw's FullCalendar to: 1- Change the calendar from showing weekends to not show weekends and vice versa. 2- To dynamically change the timeslot interval from say 30 minutes to 60 minutes.
In other words, what I am trying to do is:
//Clicking the button that shows Saturday and Sunday too
$('#weekend-yes').click(function(){
$('#weekend-yes').hide();
$('#weekend-no').fadeIn();
//HYPOTHETICALLY DO THIS
$('#calendar').fullCalendar('option', 'weekends', true/false);
});
If something like that is not possible, what would be the best workaround? I guess I could have a second calendar which is a replica of the first, but that would be too much replication.
Appreciate any help I can get..
try this:
$('#values').click(function(){
var weekend = $('#calendar').fullCalendar('option', 'weekends');
if (weekend){
$('#values').text('Show weekend');
$('.fc-header').remove();
$('.fc-content').remove();
$('#calendar').fullCalendar({ firstDay:1, height:650,
weekMode:'liquid', weekends:false,
header: {left: 'prev,next today',
center: 'title',
right: 'month,
agendaWeek,agendaDay'}});
} else {
$('#values').text('Hide weekend');
$('.fc-header').remove();
$('.fc-content').remove();
$('#calendar').fullCalendar({ firstDay:1, height:650,
weekMode:'liquid', weekends:true,
header: {left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'}});
};
});
Update for 2017: FullCalendar added a weekend setter in 2.9.0 (7-10-2016), so no calendar destroy or custom view manipulation is necessary anymore.
Here's how I implemented a weekend toggle in my production app using FullCalendar 3.1.0:
var calendarOptions = {
...
customButtons: {
toggleWeekends: {
text: 'Show Weekends',
click: function() {
toggleWeekends();
},
},
},
...
header: {
left: 'today toggleWeekends',
...
},
weekends: false,
}
function toggleWeekends() {
var weekends = $('#calendar').fullCalendar('option', 'weekends');
var text = 'Show Weekends';
if (weekends == false) {
text = 'Hide Weekends';
}
$('#calendar').fullCalendar('option', {
customButtons: {
toggleWeekends: {
text: text,
click: function() {
toggleWeekends();
},
},
},
weekends: !weekends,
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With