FullCalendar会跳回到当前日期,而不是停留在当前月份 [英] FullCalendar skips back to current date rather than staying on current month

查看:80
本文介绍了FullCalendar会跳回到当前日期,而不是停留在当前月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了FullCalendar并运行良好,可以从数据库中提取课程.

I have FullCalendar installed and working great, pulling in courses from my database.

您可以通过单击再次提交页面但通过不同标准的按钮来查看不同的课程.

You can view different courses based on clicking a button that submits the page again but passes different criteria.

问题在于,在重新加载页面和新内容时,它会跳回到当前日期,当您查看未来3个月的课程时,这会很烦人!

The Issue is that on reloading of the page and the new content it skips back to the current date which is rather annoying when when you are looking at courses 3 months into the future!!

有人知道刷新日历后如何使日历返回到您所在的页面吗?

Does anybody know how to make the calendar go back to the page you where on after you have refreshed the page???

我觉得这可能与getdate有关,因为我使以下代码正常工作,但似乎无法将结果通过URL传递回日历设置.

I have a feeling it might be something to do with getdate as I got the following code to work but can't seem to pass the result back through the URL and into the calendar setup.

$('#my-button').click(function() {
    var d = $('#calendar').fullCalendar('getDate');
    alert("The current date of the calendar is " + d);
});

推荐答案

如果使用 jquery.cookie,您可以将当前查看的日期存储在正在查看的页面的Cookie中,并在重新加载页面时使用该值设置defaultDate.在初始化日历时将这些作为选项传递进来:

If you use jquery.cookie you can store the currently viewed date in a cookie for the page being viewed and use that value to set the defaultDate when the page reloads. Pass these in as options when you initialise your calendar:

defaultView: Cookies.get('fullCalendarCurrentView') || 'month',
defaultDate: Cookies.get('fullCalendarCurrentDate') || null,
viewRender: function(view) {
  Cookies.set('fullCalendarCurrentView', view.name, {path: ''});
  Cookies.set('fullCalendarCurrentDate', view.intervalStart.format(), {path: ''});
}

此代码还保存了当前视图(例如,月,日等)

This code also saves the current view (e.g. month, day etc...)

这篇关于FullCalendar会跳回到当前日期,而不是停留在当前月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆