Last active
August 14, 2024 05:32
-
-
Save juanbrujo/c4a0a8d36fc64860f487 to your computer and use it in GitHub Desktop.
jQuery FullCalendar.js: disable prev/next button for past/future dates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#calendar').fullCalendar({ | |
viewRender: function(currentView){ | |
var minDate = moment(), | |
maxDate = moment().add(2,'weeks'); | |
// Past | |
if (minDate >= currentView.start && minDate <= currentView.end) { | |
$(".fc-prev-button").prop('disabled', true); | |
$(".fc-prev-button").addClass('fc-state-disabled'); | |
} | |
else { | |
$(".fc-prev-button").removeClass('fc-state-disabled'); | |
$(".fc-prev-button").prop('disabled', false); | |
} | |
// Future | |
if (maxDate >= currentView.start && maxDate <= currentView.end) { | |
$(".fc-next-button").prop('disabled', true); | |
$(".fc-next-button").addClass('fc-state-disabled'); | |
} else { | |
$(".fc-next-button").removeClass('fc-state-disabled'); | |
$(".fc-next-button").prop('disabled', false); | |
} | |
} | |
}); |
Thank you, I was in great need of this solution.
Clean and simple solution that worked perfectly from the go. Thanks!
Thanks!
If they need to disappear with the buttons just assign to the Header as follows.
header: {
left: '',
center: 'title',
right: ''
},
Thanks a lot!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how can i disable previous button that user not to enter past date?
i'd used this condition,but its not working
if($("#startdatepicker1").datepicker("getDate").getDate() < today)