Skip to content

Commit bdd2362

Browse files
committed
Merge remote branch 'kzys/trac-6656'
2 parents fef60bd + 2063a11 commit bdd2362

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

tests/unit/datepicker/datepicker.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ <h2 id="qunit-userAgent"></h2>
4949

5050
<div id="qunit-fixture">
5151
<p><input type="text" id="inp"/><input type="text" id="alt"/><div id="inl"></div></p>
52+
<p><input type="text" id="inp2"/></p>
5253
</div>
5354

5455
</body>

tests/unit/datepicker/datepicker_events.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ test('events', function() {
112112
inp.val('02/04/2008').datepicker('show').
113113
simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_END});
114114
equals(selectedDate, '', 'Callback close date - ctrl+end');
115+
116+
var inp2 = init('#inp2');
117+
inp2.datepicker().datepicker('option', {onClose: callback}).datepicker('show');
118+
inp.datepicker('show');
119+
equals(selectedThis, inp2[0], 'Callback close this');
115120
});
116121

117122
})(jQuery);

ui/jquery.ui.datepicker.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,9 @@ $.extend(Datepicker.prototype, {
614614
return;
615615
var inst = $.datepicker._getInst(input);
616616
if ($.datepicker._curInst && $.datepicker._curInst != inst) {
617+
if ( $.datepicker._datepickerShowing ) {
618+
$.datepicker._triggerOnClose($.datepicker._curInst);
619+
}
617620
$.datepicker._curInst.dpDiv.stop(true, true);
618621
}
619622
var beforeShow = $.datepicker._get(inst, 'beforeShow');
@@ -759,6 +762,14 @@ $.extend(Datepicker.prototype, {
759762
return [position.left, position.top];
760763
},
761764

765+
/* Trigger custom callback of onClose. */
766+
_triggerOnClose: function(inst) {
767+
var onClose = this._get(inst, 'onClose');
768+
if (onClose)
769+
onClose.apply((inst.input ? inst.input[0] : null),
770+
[(inst.input ? inst.input.val() : ''), inst]);
771+
},
772+
762773
/* Hide the date picker from view.
763774
@param input element - the input field attached to the date picker */
764775
_hideDatepicker: function(input) {
@@ -781,10 +792,7 @@ $.extend(Datepicker.prototype, {
781792
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
782793
if (!showAnim)
783794
postProcess();
784-
var onClose = this._get(inst, 'onClose');
785-
if (onClose)
786-
onClose.apply((inst.input ? inst.input[0] : null),
787-
[(inst.input ? inst.input.val() : ''), inst]); // trigger custom callback
795+
$.datepicker._triggerOnClose(inst);
788796
this._datepickerShowing = false;
789797
this._lastInput = null;
790798
if (this._inDialog) {

0 commit comments

Comments
 (0)