Can't get jQueryUI datepicker option beforeShowDay
to work.
I've tried different help topics I've found but I can't get it working.
I get this error
Uncaught TypeError: Cannot read property '0' of undefined
This is my JS. but it doesn't seems to work
<script type="text/javascript">
jQuery(document).ready(function () {
var your_dates = [new Date(13, 5, 5), new Date(13, 5, 10)];
jQuery("div#event-calender").datepicker({
beforeShowDay: function (date) {
if (jQuery.inArray(date.toString(), your_dates) != -1) {
return [true, 'highlight'];
}
}
});
});
</script>
Change your
beforeShowDay
toEdit
Either change
your_dates
toor use something like this instead of
jQuery.inArray(...)
You need to always return an array, not just when a condition matches.
From the documentation:
FIDDLE