简体   繁体   中英

FullCalendar.io get selected day of the week

Im using the following plugin: FullCalendar.js by : [https://fullcalendar.io/][1]

I am using this with ajax and JSON with an API. 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/

But im not sure that is correct?

Per your comment, yes, you would want dayClick() for this:

$('#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/

Ref. 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/ .

Based on your comments, I think the dayClick callback is the most likely option for you.

$('#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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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