FullCalendar jQuery! Can I Select Only one timeslots by clicking?

2k Views Asked by At

In the Calendar "FullCalendar" made by http://arshaw.com/fullcalendar/

I need the user can only select one timeslots by clicking in agendaWeek view mode!

2

There are 2 best solutions below

1
On BEST ANSWER

The more info you can provide, the more relevant answers we can provide. From what I understand, you can do this by combining dayclick with the select method. http://arshaw.com/fullcalendar/docs/selection/select_method/

Use dayclick to listen for a times lot selection and then use the select method to select the times slot given. I haven't tested this myself but in theory it should work.

0
On

First define your minutes for slot

MINUTES_FOR_SLOT = 60;

then create your calendar using your minutes for slot, and validate the difference between start and end dates selected, if the difference in minutes is greater than MINUTES_FOR_SLOT then return false

           $('#calendar').fullCalendar({
                defaultView  : 'agendaWeek',
                slotMinutes  : MINUTES_FOR_SLOT,
                select: function(start, end) {

                    var a = moment(start.toString("yyyy-MM-dd HH:mm"));
                    var b = moment(end.toString("yyyy-MM-dd HH:mm"));
                    var diffMinutes = b.diff(a, 'minutes')
                    if(diffMinutes > MINUTES_FOR_SLOT) {
                        alert("multiple slot selection is not available");
                        return false;            
                    }
                },
             });