aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/unit/datepicker/datepicker.html1
-rw-r--r--tests/unit/datepicker/datepicker_events.js5
-rw-r--r--ui/jquery.ui.datepicker.js16
3 files changed, 18 insertions, 4 deletions
diff --git a/tests/unit/datepicker/datepicker.html b/tests/unit/datepicker/datepicker.html
index fa346c6c9..d0c2c8c8c 100644
--- a/tests/unit/datepicker/datepicker.html
+++ b/tests/unit/datepicker/datepicker.html
@@ -49,6 +49,7 @@
<div id="qunit-fixture">
<p><input type="text" id="inp"/><input type="text" id="alt"/><div id="inl"></div></p>
+ <p><input type="text" id="inp2"/></p>
</div>
</body>
diff --git a/tests/unit/datepicker/datepicker_events.js b/tests/unit/datepicker/datepicker_events.js
index 84ca2f98e..bf48c9c8a 100644
--- a/tests/unit/datepicker/datepicker_events.js
+++ b/tests/unit/datepicker/datepicker_events.js
@@ -112,6 +112,11 @@ test('events', function() {
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_END});
equals(selectedDate, '', 'Callback close date - ctrl+end');
+
+ var inp2 = init('#inp2');
+ inp2.datepicker().datepicker('option', {onClose: callback}).datepicker('show');
+ inp.datepicker('show');
+ equals(selectedThis, inp2[0], 'Callback close this');
});
})(jQuery);
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js
index 519d4dfdb..021041202 100644
--- a/ui/jquery.ui.datepicker.js
+++ b/ui/jquery.ui.datepicker.js
@@ -614,6 +614,9 @@ $.extend(Datepicker.prototype, {
return;
var inst = $.datepicker._getInst(input);
if ($.datepicker._curInst && $.datepicker._curInst != inst) {
+ if ( $.datepicker._datepickerShowing ) {
+ $.datepicker._triggerOnClose($.datepicker._curInst);
+ }
$.datepicker._curInst.dpDiv.stop(true, true);
}
var beforeShow = $.datepicker._get(inst, 'beforeShow');
@@ -759,6 +762,14 @@ $.extend(Datepicker.prototype, {
return [position.left, position.top];
},
+ /* Trigger custom callback of onClose. */
+ _triggerOnClose: function(inst) {
+ var onClose = this._get(inst, 'onClose');
+ if (onClose)
+ onClose.apply((inst.input ? inst.input[0] : null),
+ [(inst.input ? inst.input.val() : ''), inst]);
+ },
+
/* Hide the date picker from view.
@param input element - the input field attached to the date picker */
_hideDatepicker: function(input) {
@@ -781,10 +792,7 @@ $.extend(Datepicker.prototype, {
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
if (!showAnim)
postProcess();
- var onClose = this._get(inst, 'onClose');
- if (onClose)
- onClose.apply((inst.input ? inst.input[0] : null),
- [(inst.input ? inst.input.val() : ''), inst]); // trigger custom callback
+ $.datepicker._triggerOnClose(inst);
this._datepickerShowing = false;
this._lastInput = null;
if (this._inDialog) {