Reputation: 3957
This is related to post jQuery UI Datepicker Today Link
Using the code below results in the "Today" button being rendered in black. However, it only works once because when the "Today" button is clicked it goes back to being grayed out. Is there a better way to handle this so that the color rendering is permanent?
$(document).ready(function() {
$(".datePicker").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd",
yearRange: "2000:c+1",
showButtonPanel: true
});
$('.datePicker').click(function () {
$('button.ui-datepicker-current').removeClass('ui-priority-secondary').addClass('ui-priority-primary');
});
});
Update: https://jsfiddle.net/megoo1xk/14/
Upvotes: 1
Views: 598
Reputation: 2664
since datepicker only have beforeShow event instead onShow, onOpen or afterShow. We should build it by ourself.
$.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));
}
Reference: afterShow event on jquery datepicker
if we join with your function, that will be like this fiddle
Upvotes: 2