简体   繁体   English

FullCalendar.io获取星期几

[英]FullCalendar.io get selected day of the week

Im using the following plugin: FullCalendar.js by : [https://fullcalendar.io/][1] 我正在使用以下插件:FullCalendar.js,作者: [https://fullcalendar.io/][1]

I am using this with ajax and JSON with an API. 我将它与带有API的ajax和JSON一起使用。 however i would like to know if its possible to get the selected day of the week as I want to make certain conditions happen if that day is a Saturday for example: 但是我想知道是否有可能获得一周中的选定日期,因为我想使某些条件发生,例如那天是星期六:

Is this possible? 这可能吗? I have been looking in the docs and came across this: 我一直在寻找文档,并发现了这一点:

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

But im not sure that is correct? 但是我不确定那是正确的吗?

Per your comment, yes, you would want dayClick() for this: 根据您的评论,是的,您需要使用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);
    }
});

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

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

For a full list of all fullcalendar click events, check out the docs at https://fullcalendar.io/docs/mouse/ . 有关所有全日历点击事件的完整列表,请访问https://fullcalendar.io/docs/mouse/查看文档。

Based on your comments, I think the dayClick callback is the most likely option for you. 根据您的评论,我认为dayClick回调是您最有可能的选择。

$('#calendar').fullCalendar({
    //....
    dayClick: function(date, jsEvent, view) {
     var dow = date.day(); //this will give you the day of the week. Sunday is 0, Saturday is 6.
     //you can now use this to make your ajax call and whatever else you need
    }
});

Note that if there are events in that day, and the user clicks on the actual event (rather than the empty areas around it), the dayClick callback does not fire. 请注意,如果当天发生了事件,并且用户单击了实际事件(而不是事件周围的空白区域),则不会触发dayClick回调。

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

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