代码之家  ›  专栏  ›  技术社区  ›  CFML_Developer

如何从当天开始每7天突出显示一次?

  •  0
  • CFML_Developer  · 技术社区  · 6 年前

    我不仅要选择每7天(+7为下一天或-7为前一天)作为默认的一天,并改变其颜色。
    https://fullcalendar.io/docs/external-dragging-demo 我尝试过几件事都没有成功:

     $('.fc-prev-button').click(function(){
        	//currCalDate is global variable to store the current day
        	 currCalDate.setDate(currCalDate.getDate() - 7);
        	 console.log(currCalDate);
        	 $('#calendar').fullCalendar('gotoDate', currCalDate);
        });
        
        $('.fc-next-button').click(function(){
          currCalDate.setDate(currCalDate.getDate() + 7);
        $('#calendar').fullCalendar('gotoDate', currCalDate);
        });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

    然后尝试在FC定义中使用dayRender,或者可以使用viewRender执行某些操作?

    dayRender: function (date, cell) {
                        var today = new Date(currCalDate);
                        date = moment(date).toDate();
                        if (date.getDate() === today.getDate()) {
                            cell.css("background-color", "red");
                        }
                    },
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   Therichpost    6 年前

    在这里,您可以查看下一个第7天的重点代码:

        dayRender: function (date, cell) {
                    var today = new Date();
                    date = moment(date).toDate();
    
                    dateFromplus = moment().add(7,'d').format('YYYY-MM-DD');
                    $(".fc-day[data-date='"+dateFromplus+"']").css("background-color", "red");
    
                    dateFromminus = moment().subtract(7,'d').format('YYYY-MM-DD');
                    $(".fc-day[data-date='"+dateFromminus+"']").css("background-color", "red");
    
                }
    

    更多完整日历信息: fullcalendar hacks