mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Datepicker: Added onSelect.apply() call to _doKeyDown method when enter button pushed if onSelect is defined. Fixed #7124 - Datepicker: onSelect does not fire when enter button is pushed
This commit is contained in:
parent
5c34cea06f
commit
a56aa861b1
@ -41,6 +41,11 @@ test('events', function() {
|
|||||||
simulate('keydown', {keyCode: $.simulate.VK_ESC});
|
simulate('keydown', {keyCode: $.simulate.VK_ESC});
|
||||||
equals(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
|
equals(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
|
||||||
'Callback selected date - esc');
|
'Callback selected date - esc');
|
||||||
|
var dateStr = '02/04/2008';
|
||||||
|
inp.val(dateStr).datepicker('show').
|
||||||
|
simulate('keydown', {keyCode: $.simulate.VK_ENTER});
|
||||||
|
equals(dateStr, selectedDate,
|
||||||
|
'onSelect is called after enter keydown');
|
||||||
// onChangeMonthYear
|
// onChangeMonthYear
|
||||||
inp.datepicker('option', {onChangeMonthYear: callback2, onSelect: null}).
|
inp.datepicker('option', {onChangeMonthYear: callback2, onSelect: null}).
|
||||||
val('').datepicker('show');
|
val('').datepicker('show');
|
||||||
|
7
ui/jquery.ui.datepicker.js
vendored
7
ui/jquery.ui.datepicker.js
vendored
@ -529,6 +529,13 @@ $.extend(Datepicker.prototype, {
|
|||||||
$.datepicker._currentClass + ')', inst.dpDiv);
|
$.datepicker._currentClass + ')', inst.dpDiv);
|
||||||
if (sel[0])
|
if (sel[0])
|
||||||
$.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
|
$.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
|
||||||
|
var onSelect = $.datepicker._get(inst, 'onSelect');
|
||||||
|
if (onSelect) {
|
||||||
|
var dateStr = $.datepicker._formatDate(inst);
|
||||||
|
|
||||||
|
// trigger custom callback
|
||||||
|
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
$.datepicker._hideDatepicker();
|
$.datepicker._hideDatepicker();
|
||||||
return false; // don't submit the form
|
return false; // don't submit the form
|
||||||
|
Loading…
Reference in New Issue
Block a user