Reputation: 179
We are trying to add html on jquery selected date. we know we can put color via "beforeShowDay" function, But we didn't find any reference by which we can add html on selected date.
For example we are trying to achieve this
For this wrote this code
$('#txtDate').datepicker({
beforeShowDay: function(date) {
var Highlight = SelectedDates[date];
if (Highlight) {
return [true, "Highlighted", Highlight];
}
else {
return [true, '', ''];
}
}
});
can any one help us in this? Any type of help is appreciated.
Upvotes: 2
Views: 420
Reputation: 11
First add event afterShow:
$(function(){
$.datepicker._updateDatepicker_original = $.datepicker._updateDatepicker;
$.datepicker._updateDatepicker = function(inst) {
$.datepicker._updateDatepicker_original(inst);
var afterShow = this._get(inst, 'afterShow');
if (afterShow)
afterShow.apply((inst.input ? inst.input[0] : null)); // trigger custom callback
}
})
Then add classes on beforeShowDay:
beforeShowDay: function(date) {
var highlight = eventDates[date];
if(highlight){
return [true, 'someClass someClass someClass', ''];
}else{
return [true, '', ''];
}
},
Now you can modify html of date on afterShow event using someClass.
Upvotes: 1