I am using jquery\'s datepicker where a list of items is populated from an ajax call whenever a date is picked from an inline datepicker object. The script works perfect exc
Here is what I came up with and seems to be the best solution:
var inst = $.datepicker._getInst($("#date")[0]);
$.datepicker._get(inst, 'onSelect').apply(inst.input[0], [$("#date").datepicker('getDate'), inst]);
And it works like a charm
The accepted answer was not something I could use, because I was using common code that added hotkey functionality on all datepickers in my web application (to set value to today, +1 day, +1 month, etc.), and wanted to make sure onselect was called to validate the date value that was calculated with the hot key.
I took this from the source code of the datepicker.js file. Note thiat this
should be replaced with your datepicker element. In my case, I was calling this from a keydown
event.
// this is SUCH a hack. We need to call onselect to call any
// specific validation on this input. I stole this from the datepicker source code.
var inst = $.datepicker._getInst(this),
onSelect = $.datepicker._get(inst, "onSelect");
if (onSelect) {
dateStr = $.datepicker._formatDate(inst);
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
}
I use another way, trigger 2 events
jQuery('#my-calendar').datepicker( "setDate", "09/29/2020" )
jQuery('#my-calendar .ui-state-active').trigger('click')