jQuery UI beforeShowDay in inline datepicker crashing

瘦欲@ 提交于 2019-12-11 04:37:18

问题


Fairly straight question:

If I have an inline datepicker (call .datepicker() on a div instead of an input) and use the beforeShowDay function, everything breaks.

I've created a jsFiddle here so you can test it: http://jsfiddle.net/MBwSe/1/

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!


回答1:


You have to return an array from beforeShowDay. From the docs:

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.

Modified Fiddle: http://jsfiddle.net/MBwSe/2/



来源:https://stackoverflow.com/questions/12064606/jquery-ui-beforeshowday-in-inline-datepicker-crashing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!