@@ -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