mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Datepicker: onClose callback should be triggered by show. Fixed #6656 - onClose event not triggered.
(cherry picked from commit 2063a113d6
)
This commit is contained in:
parent
4e3f8bdb70
commit
3124864541
@ -48,6 +48,7 @@
|
||||
|
||||
<div id="main" style="position: absolute; top: -10000px; left: -10000px;">
|
||||
<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>
|
||||
|
@ -117,6 +117,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);
|
||||
|
16
ui/jquery.ui.datepicker.js
vendored
16
ui/jquery.ui.datepicker.js
vendored
@ -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');
|
||||
@ -757,6 +760,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) {
|
||||
@ -777,10 +788,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) {
|
||||
|
Loading…
Reference in New Issue
Block a user