JQuery DatePicker: Disable Today Button Selection

This is due to jQuery UI Datepicker Today Link post

Using the code below, the Today button is displayed in black. However, it only works once, because when the Today button is clicked, it returns to being grayed out. Is there a better way to handle this so that the color rendering is consistent?

$(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/

0
source share
1 answer

since datepicker only has a beforeShow event instead of onShow, onOpen or afterShow. We must build it ourselves.

 $.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)); } 

Link: afterShow event on jquery datepicker

if we join your function, it will look like this fiddle

+1
source

Source: https://habr.com/ru/post/1275718/


All Articles