FullCalendar how to stop select on Inverse Backgro

2019-07-29 07:08发布

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:

enter image description here

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条回答
Evening l夕情丶
2楼-- · 2019-07-29 07:44

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;
},
查看更多
登录 后发表回答