How to disable a range of dates depends on the work hours?

六月ゝ 毕业季﹏ 提交于 2019-12-25 12:45:16

问题


I want to close a range of hours cells so that the user can't book on that specific hour, i've created a modal windows that allows the admin to set his own working hours every day all the week.

Update:

I've found a solution, i have to add this little magic to my fullcalendar businessHours where it can take any list of hours, but the problem is how to disable the event click on the non-business hour ?

here is my new code:

$('#calendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay,listMonth',
    },
    defaultView: 'agendaWeek',
    businessHours: 
    [
        {
            dow: [0], // Sunday
            start: '08:00',
            end: '13:00'
        },
        {
            dow: [1], // Monday
            start: '09:00',
            end: '12:00'
        }, {
            dow: [2], // Tuseday
            start: '13:00',
            end: '15:00'
        }, {
            dow: [3], // Wedensday
            start: '15:00',
            end: '17:00'
        }, {
            dow: [4], // Thursday
            start: '12:00',
            end: '19:00'
        }, {
            dow: [5], // Friday
            start: '10:00',
            end: '15:00'
        }, {
            dow: [6], // Saturday
            start: '11:00',
            end: '20:00'
        }
    ],
    select: function(mydate, start, end, event, jsEvent, allDay, businessHours, view, element) {

        var DaysOK = [1,2,3,4,5,6,7];
        var mydateObj = new Date(mydate);
        var chosenDay = mydateObj.getUTCDay();

        if( // Clicked event hour in business hours ){
            alert('You can book!);
        } else {
            alert('You can\'nt book');
        }
    }

And why console.log(businessHours) inside console gives undefined ??

Please any help or suggestions would be tons appreciated .

来源:https://stackoverflow.com/questions/47241352/how-to-disable-a-range-of-dates-depends-on-the-work-hours

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!