完整日历“视图”可缓存的

发布于 2024-11-07 09:32:44 字数 212 浏览 0 评论 0原文

我想知道 FullCalendar 中是否缺少一个选项。

我目前的默认视图是“月”。但我希望发生的是,如果用户查看“周”视图,则下次用户访问网站时将显示“周”视图而不是月份。我想知道如何在不使用数据库的情况下解决这个问题。

我知道 jQuery UI Tabs 具有使用“缓存”功能的这种能力...我也可以在这里实现吗?如果是这样,怎么办?

任何方向将不胜感激。

I am wondering if there is an option that i'm missing within FullCalendar.

I currently have the default view to be 'month'. But what I would like to happen is have it that IF the user views the "week" view, that the next time the user visits the website that the "week" view will show instead of the month. I am wondering about setting this out without using a DB.

I know jQuery UI Tabs has this ability using the 'cache' feature... is this something I can implement here as well? If so, how?

Any direction would be appreciative.

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

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

发布评论

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

评论(5

囍笑 2024-11-14 09:32:44

changeView 不起作用,因为在设置日历时 viewDisplay 在它之前被调用。

这是有效的:

在初始化对象中,添加:

defaultView: $.cookie('fullcalendar_defaultView') || 'month',

viewDisplay: function(view) { $.cookie('fullcalendar_defaultView', view.name); }

changeView doesn't work, as viewDisplay is called before it when the calendar is setup.

here's what works:

in the initializing object, add:

defaultView: $.cookie('fullcalendar_defaultView') || 'month',

viewDisplay: function(view) { $.cookie('fullcalendar_defaultView', view.name); }
柏拉图鍀咏恒 2024-11-14 09:32:44

您可以使用选项卡使用的库 jQuery.cookie 将此设置存储在 cookie 中。由于您没有提供代码,因此您如何处理这个问题以及在哪里设置它更多是您需要回答的问题。

You can store this setting in a cookie using jQuery.cookie which is the library that the Tabs uses. How you handle this and where it is setup is more of a question that you need to answer, since you provided no code.

素衣风尘叹 2024-11-14 09:32:44

您可以使用 viewdisplay 事件,

一个好的 cookie 插件是 http://plugins.jquery.com/project/Cookie

You can use viewdisplay event

a good cookie plugin is http://plugins.jquery.com/project/Cookie

落叶缤纷 2024-11-14 09:32:44

在您的情况下,您必须将代码放入 viewDisplay 事件中。
http://arshaw.com/fullcalendar/docs/display/viewDisplay/

类似的东西像这样。

$('#calendar').fullCalendar({
    viewDisplay: function(view) {
        setCookie("lastView", view.name);
    }
});

您可以在此处获取有关视图存储哪些信息的更多信息
http://arshaw.com/fullcalendar/docs/views/View_Object/

然后
你所要做的就是在页面加载时使用changeView(例如在jQuery Ready或其他方法中)

http://arshaw.com/fullcalendar/docs/views/changeView/

类似的东西

.fullCalendar( 'changeView', getCookie("lastView") )

有很多 jQuery 的 cookie 插件,但它们的操作方式都略有不同。我的答案基于 http:// /jquery-howto.blogspot.com/2010/09/jquery-cookies-getsetdelete-plugin.html 可能有更好的地方。

In your case you would have to put code in the the viewDisplay event.
http://arshaw.com/fullcalendar/docs/display/viewDisplay/

Something similar like this.

$('#calendar').fullCalendar({
    viewDisplay: function(view) {
        setCookie("lastView", view.name);
    }
});

You can get more information on what inforamtion the view stores here
http://arshaw.com/fullcalendar/docs/views/View_Object/

Then,
all you would have to do is use the the changeView when the page loads with a method (for example in the jQuery ready or something)

http://arshaw.com/fullcalendar/docs/views/changeView/

something similar to

.fullCalendar( 'changeView', getCookie("lastView") )

There are many cookie plugins to jQuery but they all operate slightly different. I based my anser on some pureJS code found at http://jquery-howto.blogspot.com/2010/09/jquery-cookies-getsetdelete-plugin.html there could be much better ones out ther somewhere.

仄言 2024-11-14 09:32:44

在版本:3.0.0 viewDisplay 已重命名为 viewRender,因此当前代码应如下所示:


默认视图:$.cookie('fullcalendar_defaultView') || '月',
viewRender: function(view) { $.cookie('fullcalendar_defaultView', view.name); }

In version: 3.0.0 viewDisplay has been renamed to viewRender, so current code should like that:


defaultView: $.cookie('fullcalendar_defaultView') || 'month',
viewRender: function(view) { $.cookie('fullcalendar_defaultView', view.name); }

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