I am initializing jquery ui's datepicker as follows:
var datesArray=['3/7/2016','3/12/2016']
$('#datepicker').datepicker({
inline: true,
beforeShowDay: function (date) {
var theday = (date.getMonth()+1) +'/'+
date.getDate()+ '/' +
date.getFullYear();
return [true,$.inArray(theday, datesArray) >=0 ? "specialDate":''];
}
});
This creates the calendar with the class specialDate
applied to all dates in datesArray
.
Additionally, I need to add a unique data attribute value (something like data-value="39"
) to these same dates on initialization of the datepicker, but I am not sure how to select the dates.
I can use something like
var datavalues = {
"3/7/2016" : "38",
"3/12/2016" : "39"
};
where 38
and 39
are the data-value
s.
This question about adding a custom parameter gets me close, but I'm not sure exactly how to use this to just add the data attributes on creation.