内联日期选择器中的jQuery UI beforeShowDay崩溃 [英] jQuery UI beforeShowDay in inline datepicker crashing
问题描述
一个直截了当的问题:
如果我有一个内联日期选择器(在div而不是输入上调用.datepicker())并使用beforeShowDay函数,则一切都会中断.
If I have an inline datepicker (call .datepicker() on a div instead of an input) and use the beforeShowDay function, everything breaks.
我在这里创建了一个jsFiddle,因此您可以对其进行测试: http://jsfiddle.net/MBwSe/1/
I've created a jsFiddle here so you can test it: http://jsfiddle.net/MBwSe/1/
beforeShowDay函数在我使用的前4天(2012年7月29日至2012年8月1日)有效,然后由于以下错误而在2012年8月2日中断:
The beforeShowDay function works for the first 4 days to me (jul 29 to aug 01 2012) and then breaks on aug 02 2012 with this error:
TypeError: daySettings is undefined
[Break On This Error]
line 8827
var unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
有什么想法吗?疯了我!
Any ideas what's going on? Driving me nuts!
推荐答案
您必须从beforeShowDay
返回一个数组.从文档中:
You have to return an array from beforeShowDay
. From the docs:
该函数将日期作为参数,并且必须返回一个数组,其中 [0]等于true/false,表示此日期是否为 可选,[1]等于CSS类名,默认为" 演示文稿,以及[2]此日期的可选弹出式工具提示.它是 在日期选择器中的每一天都显示之前调用它.
The function takes a date as a parameter and must return an array with [0] equal to true/false indicating whether or not this date is selectable, [1] equal to a CSS class name(s) or "" for the default presentation, and [2] an optional popup tooltip for this date. It is called for each day in the datepicker before it is displayed.
修改过的小提琴:: http://jsfiddle.net/MBwSe/2/
这篇关于内联日期选择器中的jQuery UI beforeShowDay崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!