Problem is, how to disable selectable on PAST DATES in fullcalendar's month/week view.
I want to user not allowed to click/select the on past dates.
Here is some googled code snippet I am trying to implement on event rendering:
selectable: true, selectHelper: false, select: function(start, end, allDay) { var appdate = jQuery.datepicker.formatDate('<?php echo $DPFormat; ?>', new Date(start)); jQuery('#appdate').val(appdate); jQuery('#AppFirstModal').show(); }, eventRender: function(event, element, view) { var view = 'month' ; if(event.start.getMonth() !== view.start.getMonth()) { return false; } },
But its not working though.
I tried bellow CSS too and this help me to hide past date text only, but selectable is still working on pastdate box.
.fc-other-month .fc-day-number { display:none; }
I am really stuck with this problem. Please someone help me out. Thanks...
The calendar's dates can change any time the user does the following: click the prev/next buttons, change the view, click a navlink. The dates can also change when the current-date is manipulated via the API, such as when gotoDate is called. datesSet is called after the new date range has been rendered.
Detect when the user clicks on dates or times. Give the user the ability to select multiple dates or time slots with their mouse or touch device. Allows a user to highlight multiple days or timeslots by clicking and dragging.
click(function(){ var fetchDate = $(this). data("date"); $("#displayDate"). text(fetchDate); });
This option is available from v2. 4.0 see fullcalendar.io/docs/text/displayEventTime - You need to set it as option of fullCalendar and it affects all events. Or use CSS . fc-time{ display : none; } .
I have done this in my fullcalendar and it's working perfectly.
you can add this code in your select function.
select: function(start, end, allDay) { var check = $.fullCalendar.formatDate(start,'yyyy-MM-dd'); var today = $.fullCalendar.formatDate(new Date(),'yyyy-MM-dd'); if(check < today) { // Previous Day. show message if you want otherwise do nothing. // So it will be unselectable } else { // Its a right date // Do something } },
I hope it will help you.
I like this approach:
select: function(start, end) { if(start.isBefore(moment())) { $('#calendar').fullCalendar('unselect'); return false; } }
It will essentially disable selection on times before "now".
Unselect method
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