FullCalendar how to stop select on Inverse Backgro

2019-07-29 07:35发布

问题:

I am using FullCalendar JavaScript Event Calendar component.

How do I stop users from creating (drag to select) events in the Inverse Background (green) areas:

Method selectOverlap only fires if the user selects on the white area, not the green, so I cannot use this method to stop the selection in the green area.

Method selectAllow only gives me access to selectInfo which has start and end and resourceId properties, so there is nothing that changes between the white and green that I can evaluate on.

回答1:

Solved by using the selectAllow method and looping over the the clientEvents

selectAllow : function(selectInfo) 
{               
     var events = $('#calendar').fullCalendar('clientEvents', function(evt) 
     {
         return (evt.start <= selectInfo.start 
                 && evt.end >= selectInfo.end 
                 && evt.resourceId == selectInfo.resourceId);
     });               

     return events.length > 0;
},