]> source.dussan.org Git - jquery-ui.git/commitdiff
Datepicker: Added onSelect.apply() call to _doKeyDown method when enter button pushed...
authormarcneuwirth <marc.neuwirth@gmail.com>
Tue, 28 Jun 2011 15:49:47 +0000 (10:49 -0500)
committerCorey Frang <gnarf@gnarf.net>
Tue, 28 Jun 2011 15:50:58 +0000 (10:50 -0500)
(cherry picked from commit a56aa861b1deb6d71ec74a77647d12d50570ea57)

tests/unit/datepicker/datepicker_events.js
ui/jquery.ui.datepicker.js

index 858cf682a11f69c304f41debf7511d0ae7eab2f1..bcd99088988e34cdf6c58f1e208ed54ec71c32f3 100644 (file)
@@ -46,6 +46,11 @@ test('events', function() {
                simulate('keydown', {keyCode: $.simulate.VK_ESC});
        equals(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
                '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
        inp.datepicker('option', {onChangeMonthYear: callback2, onSelect: null}).
                val('').datepicker('show');
index acb296fc85deca1927fd0b8baa994e80f64e6098..458ad01eccbe3d4a848189c9d5fcb6164244db90 100644 (file)
@@ -520,6 +520,13 @@ $.extend(Datepicker.prototype, {
                                                                        $.datepicker._currentClass + ')', inst.dpDiv);
                                                if (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
                                                        $.datepicker._hideDatepicker();
                                                return false; // don't submit the form