FullCalendar.io获取一周中的选定日期

时间:2017-05-15 14:02:25

标签: javascript jquery fullcalendar dayofweek

我使用以下插件:FullCalendar.js:select avg(case when AverageServiceTime < EstimateServiceTime then 1.0 else 0 end) as ServiceSuccess from Interaction I

我正在使用带有API的ajax和JSON。但是我想知道是否可以获得一周中的选定日期,因为如果那天是星期六,我想要发生某些条件:

这可能吗?我一直在查看文档并遇到了这个问题:

https://fullcalendar.io/docs/mouse/dayClick/

但我不确定这是否正确?

2 个答案:

答案 0 :(得分:1)

根据您的评论,是的,您需要dayClick()

$('#calendar').fullCalendar({
    dayClick: function(date, jsEvent, view) {
        var day = date.day(); // number 0-6 with Sunday as 0 and Saturday as 6
        alert(day);
    }
});

工作示例:https://jsfiddle.net/afn7thme/

参考。 https://fullcalendar.io/docs/mouse/dayClick/

有关所有完整日历点击事件的完整列表,请查看https://fullcalendar.io/docs/mouse/处的文档。

答案 1 :(得分:0)

根据您的评论,我认为dayClick回调最适合您。

<?php 
    if (have_posts()) : 
        $numberPost = count(have_posts());
        $isAlreadyActive = false;
        $i = 1;
        echo '<div id="random_backgrounds">';
        while (have_posts()) : 
            the_post();
            $class = "";
            if(!$isAlreadyActive && rand(0, 1) == 1 || !$isAlreadyActive && $i == $numberPost): 
                $class = "current"; 
                $isAlreadyActive = true;
            endif;
            echo '<div id="background_directors" class="' . $class . '" background_ID="' . the_ID() . '" style="background: url(' . the_post_thumbnail_url( "large" ) . ') no-repeat center center fixed" ></div>';
            $i++;
        endwhile;
        echo '</div>';
    endif; 
?>

请注意,如果当天有事件,并且用户点击实际事件(而不是周围的空白区域),则不会触发dayClick回调。

相关问题