Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to block out dates in the Fullcalendar beyond a certain date

I have a date in the future which is always 30 days ahead of the current date. It's stored in a Date object. I worked this out using:

var currentDate = new Date();
var futureBlockDate = new Date();
futureBlockDate.setDate(currentDate.getDate() + 30);

Using the FullCalendar jQuery plugin I want to visually block out any days past this date on the calendar with a different background colour so a user knows they can't click on them or create an event on those days.

What is the best way to do this with the FullCalendar? Maybe disable all dates by default, and only enable for a specific range (from today's date through to 30 days in the future)?

I think I can apply a disabled background state to all the cells using the following code:

$(".fc-widget-content").addClass("disabled");

.disabled .fc-day-content {
    background-color: #123959;
    color: #FFFFFF;
    cursor: default;
}

How can it be done?

like image 635
user unknown Avatar asked Oct 29 '13 23:10

user unknown


People also ask

How do I select multiple dates in fullCalendar?

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.

How do I set events in fullCalendar?

Here is an example of how to specify an array of events: var calendar = new Calendar(calendarEl, { events: [ { title : 'event1', start : '2010-01-01' }, { title : 'event2', start : '2010-01-05', end : '2010-01-07' }, { title : 'event3', start : '2010-01-09T12:30:00', allDay : false // will make the time show } ] });

How do I change the date on fullCalendar?

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.

How do I turn off weekends in fullCalendar?

Just go from the startDate to the endDate and check if any of those days are weekends. If so, display the alert / popup and return false. select: (start, end, allDay) => { var startDate = moment(start), endDate = moment(end), date = startDate. clone(), isWeekend = false; while (date.


1 Answers

In new version V4 of Full Calendar, there are lot of updates and you can find the settings for your need

Limits which dates the user can navigate to and where events can go.

// constrain to a discrete range
var calendar = new Calendar(calendarEl, {
  defaultView: 'dayGridMonth',
  validRange: {
    start: '2017-05-01',
    end: '2017-06-01'
  }
});

// constrain to an open-ended range
var calendar = new Calendar(calendarEl, {
  defaultView: 'dayGridMonth',
  validRange: {
    start: '2017-05-01'
  }
});
like image 148
Sajjad Ali Khan Avatar answered Sep 21 '22 22:09

Sajjad Ali Khan