简体   繁体   English

jQuery UI datepicker作为“年历”

[英]jQuery UI datepicker as “year calendar”

I'm trying to get a full year calendar from jQuery UI datepicker , where I can interact with weeks rather than days. 我正在尝试从jQuery UI datepicker获取全年日历,我可以在其中交互而不是几天。

I already found how to do the weekly part, but now I would like to display the full year, for a result similar to this : 我已经找到了做每周部分的方法,但是现在我想显示整个年度,结果类似于: 在此处输入图片说明

I managed to add the 12 months, using the numberOfMonths: 12 , but how can I set them display as a grid? 我设法使用numberOfMonths: 12添加了12个月,但是如何设置它们显示为网格呢? I tried to set a width to the container, but it doesn't do anything. 我试图为容器设置宽度,但是它什么也没做。

For the starting month, I find on an other topic that I can change default date to 1st January adding defaultDate: new Date(new Date().getFullYear(), 0,1) . 对于开始的月份,我发现另一个主题可以将默认日期更改为1月1日,并添加defaultDate: new Date(new Date().getFullYear(), 0,1) This indeed make the months starting on January, but it also move the current day selection to 1st January... I would prefer, if someone knew a way to keep the current day as default selection. 这确实使月份开始于1月,但是它也将当前日期选择移至1月1日...如果有人知道将当前日期保留为默认选择的方法,我希望这样做。

Then for the previous/next button, is it possible to make them changing year in stead of month ? 然后对于上一个/下一个按钮,是否可以使它们更改年份而不是月份? Else I think I may cheat, by adding an event handler to click 12 times instead of 1. 另外,我认为我可能会作弊,方法是添加事件处理程序以单击12次而不是1次。

Finally, I would like to move the next button back to the third month like in the picture. 最后,我想将下一个按钮移回第三个月,如图所示。 It may not be very hard using CSS, so I'm just curious if there might be a function to do it more easily. 使用CSS可能并不难,所以我很好奇是否有一个函数可以更轻松地实现它。

Here's a JSFiddle for my current code http://jsfiddle.net/AVZJh/2553/ 这是我当前代码的JSFiddle http://jsfiddle.net/AVZJh/2553/

I finally found all the missing part, result : http://jsfiddle.net/AVZJh/2625/ 我终于找到了所有缺少的部分,结果是: http : //jsfiddle.net/AVZJh/2625/

Grid & mooving previous/next button was both done changing numberOfMonths to an array : numberOfMonths: [4,3] 网格和移动上一个/下一个按钮都已完成,将numberOfMonths更改为数组: numberOfMonths: [4,3]

Previous/next switching year in stead of month was done adding stepMonths:12 添加stepMonths:12代替上一个/下一个转换年份

Starting at january without changing default date was done adding showCurrentAtPos: new Date().getMonth() 从一月开始不更改默认日期就添加了showCurrentAtPos: new Date().getMonth()

Why don't you try AnyTime . 你为什么不尝试任何时间 It has all the features you ask for. 它具有您要求的所有功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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