问题
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