将默认时间段设为1小时而不是15分钟Jquery Fullcalender

时间:2017-01-21 06:05:04

标签: javascript jquery fullcalendar fullcalendar-scheduler

我有以下代码:

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

        },      
        slotDuration: '00:15:00',
        defaultView: 'agendaDay',
        editable: false,
        droppable: true,
        drop: function() {
            if ($('#drop-remove').is(':checked')) {
                $(this).remove();
            }
    },

        viewRender: function(currentView){
                var minDate = moment();
                if (minDate >= currentView.start && minDate <= currentView.end) {
                    $(".fc-prev-button").prop('disabled', true); 
                    $(".fc-prev-button").addClass('fc-state-disabled'); 
                }
            else {
                    $(".fc-prev-button").removeClass('fc-state-disabled'); 
                    $(".fc-prev-button").prop('disabled', false); 
                }
        },
        select:function (){$('#demo-calendar').fullCalendar('unselect')},   
        eventLimit: true,
            events: [
                <?php foreach ($appowthslot as $appowthslotlist){
                    $startdate = date('Y-m-d H:i:s',strtotime($appowthslotlist->starttime));
                    $enddate = date('Y-m-d H:i:s',strtotime($appowthslotlist->endtime));
                    if($appowthslotlist->relatedappid !=0 ){
                        $color = "#ff0000";
                    }else{
                        $color = "#076903";
                    }
                ?>
                    {
                    "color": "<?php echo $color; ?>",
                    "start": "<?php echo $startdate; ?>",
                    "end": "<?php echo $enddate; ?>", 
                    },
                <?php } ?>
            ],

             eventClick: function(event) {
                    var cdate=new Date();
                    var mydate = new Date(event.start);
                    var now = mydate.toUTCString().toString();
                    var res = now.replace("GMT","");
                    var newdate= new Date(res);     
                    if(cdate>newdate){
                        alert("Appointment can't be book for previous Time");
                    }else{
                        if(event.color == "#ff0000"){
                            alert("This Slot is already Booked");
                        }else{
                            startdate = (new Date(event.start)).toISOString().slice(0, 19);
                            $('#scheduled_date #start_time_hidden').val(startdate);
                            $('#scheduled_date #start_time').val(startdate.replace("T"," "));
                            enddate = (new Date(event.end)).toISOString().slice(0, 19);
                            $('#scheduled_date #end_time_hidden').val(enddate);
                            $('#scheduled_date #end_time').val(enddate.replace("T"," "));
                            $('#scheduled_date').modal('show');
                        }

                    }
            } 
        });

我没有将默认时段设为15分钟,但我将时段间隔设为1小时。

enter image description here

当我点击周视图然后再次点击日视图时,我得到15分钟的时间段。 enter image description here

1 个答案:

答案 0 :(得分:0)

您已使用

$('#demo-calendar').fullcalendar({
        ...
        slotDuration: 15,
        ...
});

而不是它你可以尝试下面的选项

$('#demo-calendar').fullcalendar({
    ...
    slotMinutes: 15,
    ...
});

希望它的作品