简体   繁体   English

在全日历中禁用特定日期

[英]Disable a specific date in full calender

I am using full calender as a calender datepicker, and I am facing a problem. 我正在使用全压延机作为压延机的日期选择器,但遇到了问题。 I want to disable some dates from clicking (dates in red colour). 我想禁用某些单击日期(红色日期)。

在此处输入图片说明

Here is my code: 这是我的代码:

$(document).ready(function() {
  $('#calendar').fullCalendar({
    defaultDate: '<?php echo $today; ?>',
    selectable: true,
    dayClick: function(date, jsEvent, view) {
      $('input[type="text"]').val(date.format());
      //alert('Date:' + date.format());
    },
    editable: true,
    height: 400,
    eventLimit: true,
    events: [
      <?php foreach($lead as $l){?>
      {
        title: '<?php echo $l['ids']; ?>',
        start: '<?php echo $l['followup_date']; ?>',
        <?php if($l['ids'] >= $followuplimit) {?>
          backgroundColor    : '#FF0000',
          borderColor    : '#FF0000'
        <?php } else { ?>
          backgroundColor    : '#008C1F',
          borderColor    : '#008C1F'
        <?php } ?>
      },
      <?php } ?>
    ]
  });
});

You can disable date by adding disabled class to that cell. 您可以通过将disabled类添加到该单元格来禁用日期。

Logic : Just have array of dates you want to disable and check if date variable is present in your date arra and if true add disable class. 逻辑:仅包含要禁用的日期数组,并检查date变量中是否存在date变量,如果为true,则添加disable类。

$('#calendar').fullCalendar({
    ...
    dayRender: function(date, cell){
        if (date > maxDate){
            $(cell).addClass('disabled');
        }
    }
    ...
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM