Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable some dates range in a fullcalendar?

I want to disable days before and after dates range, anybody know how can I do that? (sorry for my english).

Hernan

like image 483
Hernan Avatar asked May 13 '11 12:05

Hernan


People also ask

How do I select multiple dates in Fullcalendar?

Docs Date Clicking & Selecting Give the user the ability to select multiple dates or time slots with their mouse. Allows a user to highlight multiple days or timeslots by clicking and dragging. Whether to draw a “placeholder” event while the user is dragging.

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.

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 delete a Fullcalendar event?

Event::remove Removes an event from the calendar. You must call this on an Event Object that you received elsewhere in the API, such as getEventById.


1 Answers

so you mean on the ACTUAL calendar you don't want people to book certain dates?

Look at this link

http://jsfiddle.net/ppumkin/7MTdn/

Click on a day 15 days later and the alert changes.. something like this? Yea

If that is what you mean i can try and change it for your needs..

$('#mycalendar').fullCalendar(
            {
             header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                    },


                dayClick: function( date, allDay, jsEvent, view ) { 
                    var myDate = new Date();

                    //How many days to add from today?
                    var daysToAdd = 15;

                    myDate.setDate(myDate.getDate() + daysToAdd);

                    if (date < myDate) {
                        //TRUE Clicked date smaller than today + daysToadd
                    alert("You cannot book on this day!");    
                    }
                    else
                    {
                        //FLASE Clicked date larger than today + daysToadd
                        alert("Excellent choice! We can book today..");    
                     }   


            },      

             events: [

                        {
                            title  : 'event2',
                            start  : '2011-03-10',
                            end    : '2011-05-5'
                        }
                    ]
           }); 

Please note this was written compatible for 1.6.4 and that from version 2+ most of the API has changed and things should be different but the general events and logic should be the same.

like image 70
Piotr Kula Avatar answered Oct 14 '22 08:10

Piotr Kula