Skip to content

Datepicker: Add option for onUpdateDatepicker callback [SO-2932013] #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ui/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function Datepicker() {
onSelect: null, // Define a callback function when a date is selected
onChangeMonthYear: null, // Define a callback function when the month or year is changed
onClose: null, // Define a callback function when the datepicker is closed
onUpdateDatepicker: null, // Define a callback function when the datepicker is updated
numberOfMonths: 1, // Number of months to show at a time
showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
stepMonths: 1, // Number of months to step back/forward
Expand Down Expand Up @@ -808,7 +809,8 @@ $.extend(Datepicker.prototype, {
numMonths = this._getNumberOfMonths(inst),
cols = numMonths[1],
width = 17,
activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" ),
onUpdateDatepicker = $.datepicker._get( inst, "onUpdateDatepicker");

if ( activeCell.length > 0 ) {
datepicker_handleMouseover.apply( activeCell.get( 0 ) );
Expand Down Expand Up @@ -838,6 +840,10 @@ $.extend(Datepicker.prototype, {
origyearshtml = inst.yearshtml = null;
}, 0);
}

if ( onUpdateDatepicker ) {
onUpdateDatepicker.apply( ( inst.input ? inst.input[ 0 ] : null ), [ inst ] );
}
},

// #6694 - don't focus the input if it's already focused
Expand Down