如何将当前月份发送到 jQuery FullCalendar

发布于 2024-08-11 10:15:23 字数 266 浏览 6 评论 0原文

我正在尝试使用 jquery 完整日历

我找不到如何检索用户当前所在的月份在某个时刻。

在渲染时,它在标题中设置为当前月份,但我找不到使用该信息的方法。我想将月份与附加参数(开始、结束、_)一起发送到我的 ajax 调用,但我不知道如何。

fullcalendar 定义中,如何检索当前显示的月份?

I'm trying to use jquery Full Calendar

I could not find how I can retrieve the current month a user is on at a certain moment.

On render, it is set as the current month in the title, but I can't find a way to use that info. I want to send the month to my ajax call together with additional params (start, end, _) but I don't know how.

Inside the fullcalendar definition, how do I retrieve the month currently displayed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

痴情换悲伤 2024-08-18 10:15:23

很抱歉回复得太晚了。这就是你想要的:
http://arshaw.com/fullcalendar/docs/current_date/getDate/

sorry for the really late response. here is what you would want:
http://arshaw.com/fullcalendar/docs/current_date/getDate/

寻找我们的幸福 2024-08-18 10:15:23

下面以长格式显示当前月份,但可以返回许多其他格式:
http://arshaw.com/fullcalendar/docs/utilities/formatDate/

var curDate = $('#calendar').fullCalendar('getDate');
alert("The current month of the calendar is " + $.fullCalendar.formatDate(curDate, "MMMM")); // Corrected the typo of currDate to curDate but thanks :)

The following shows the current month in long format but can return many other formats:
http://arshaw.com/fullcalendar/docs/utilities/formatDate/

var curDate = $('#calendar').fullCalendar('getDate');
alert("The current month of the calendar is " + $.fullCalendar.formatDate(curDate, "MMMM")); // Corrected the typo of currDate to curDate but thanks :)
帅的被狗咬 2024-08-18 10:15:23
     $('#calendar').fullCalendar('addEventSource', function (start, end, callback) {
            date = new Date(start);
            alert(date.getMonth());      

            $.ajax({
                    type: 'POST',
                    url: '/Employee/GetScheduleDetailedArray/',
                    async: false,
                    dataType: "json",
                    data: {
                        // our hypothetical feed requires UNIX timestamps
                        start: start,
                        end: end,
                        id: 1,
                        currentDate: $('#calendar').fullCalendar('getDate'),
                        currentMonth: date.getMonth()

                    },
                    success: function (doc) {
                        callback(doc);
                    },
                    error: function (xhr, status, error) {
                        document.appendChild(xhr.responseText);
                    }
                }); //end ajax
        });

函数 getMonth() 将返回月份的整数。

     $('#calendar').fullCalendar('addEventSource', function (start, end, callback) {
            date = new Date(start);
            alert(date.getMonth());      

            $.ajax({
                    type: 'POST',
                    url: '/Employee/GetScheduleDetailedArray/',
                    async: false,
                    dataType: "json",
                    data: {
                        // our hypothetical feed requires UNIX timestamps
                        start: start,
                        end: end,
                        id: 1,
                        currentDate: $('#calendar').fullCalendar('getDate'),
                        currentMonth: date.getMonth()

                    },
                    success: function (doc) {
                        callback(doc);
                    },
                    error: function (xhr, status, error) {
                        document.appendChild(xhr.responseText);
                    }
                }); //end ajax
        });

the function getMonth() will return an integer of the month.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文