完整日历“视图”可缓存的
我想知道 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
changeView 不起作用,因为在设置日历时 viewDisplay 在它之前被调用。
这是有效的:
在初始化对象中,添加:
changeView doesn't work, as viewDisplay is called before it when the calendar is setup.
here's what works:
in the initializing object, add:
您可以使用选项卡使用的库
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.您可以使用 viewdisplay 事件,
一个好的 cookie 插件是 http://plugins.jquery.com/project/Cookie
You can use viewdisplay event
a good cookie plugin is http://plugins.jquery.com/project/Cookie
在您的情况下,您必须将代码放入 viewDisplay 事件中。
http://arshaw.com/fullcalendar/docs/display/viewDisplay/
类似的东西像这样。
您可以在此处获取有关视图存储哪些信息的更多信息
http://arshaw.com/fullcalendar/docs/views/View_Object/
然后,
你所要做的就是在页面加载时使用changeView(例如在jQuery Ready或其他方法中)
http://arshaw.com/fullcalendar/docs/views/changeView/
类似的东西
有很多 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.
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
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.
在版本: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 toviewRender
, so current code should like that:defaultView: $.cookie('fullcalendar_defaultView') || 'month',
viewRender: function(view) { $.cookie('fullcalendar_defaultView', view.name); }