@@ -337,7 +337,9 @@ $.widget( "ui.tabs", {
337337
338338 o . selected = self . anchors . index ( el ) ;
339339
340- self . abort ( ) ;
340+ if ( self . xhr ) {
341+ self . xhr . abort ( ) ;
342+ }
341343
342344 // if tab may be closed
343345 if ( o . collapsible ) {
@@ -413,7 +415,9 @@ $.widget( "ui.tabs", {
413415 _destroy : function ( ) {
414416 var o = this . options ;
415417
416- this . abort ( ) ;
418+ if ( this . xhr ) {
419+ this . xhr . abort ( ) ;
420+ }
417421
418422 this . element . removeClass ( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" ) ;
419423
@@ -604,7 +608,9 @@ $.widget( "ui.tabs", {
604608 url = $ . data ( a , "load.tabs" ) ,
605609 eventData = self . _ui ( self . anchors [ index ] , self . panels [ index ] ) ;
606610
607- this . abort ( ) ;
611+ if ( this . xhr ) {
612+ this . xhr . abort ( ) ;
613+ }
608614
609615 // not remote
610616 if ( ! url ) {
@@ -634,6 +640,17 @@ $.widget( "ui.tabs", {
634640 self . element . find ( self . _sanitizeSelector ( a . hash ) ) . html ( response ) ;
635641 } )
636642 . complete ( function ( jqXHR , status ) {
643+ if ( status === "abort" ) {
644+ // stop possibly running animations
645+ self . element . queue ( [ ] ) ;
646+ self . panels . stop ( false , true ) ;
647+
648+ // "tabs" queue must not contain more than two elements,
649+ // which are the callbacks for the latest clicked tab...
650+ self . element . queue ( "tabs" , self . element . queue ( "tabs" ) . splice ( - 2 , 2 ) ) ;
651+
652+ delete this . xhr ;
653+ }
637654 // take care of tab labels
638655 self . _cleanup ( ) ;
639656
@@ -647,26 +664,6 @@ $.widget( "ui.tabs", {
647664 return this ;
648665 } ,
649666
650- abort : function ( ) {
651- // stop possibly running animations
652- this . element . queue ( [ ] ) ;
653- this . panels . stop ( false , true ) ;
654-
655- // "tabs" queue must not contain more than two elements,
656- // which are the callbacks for the latest clicked tab...
657- this . element . queue ( "tabs" , this . element . queue ( "tabs" ) . splice ( - 2 , 2 ) ) ;
658-
659- // terminate pending requests from other tabs
660- if ( this . xhr ) {
661- this . xhr . abort ( ) ;
662- delete this . xhr ;
663- }
664-
665- // take care of tab labels
666- this . _cleanup ( ) ;
667- return this ;
668- } ,
669-
670667 url : function ( index , url ) {
671668 this . anchors . eq ( index ) . data ( "load.tabs" , url ) ;
672669 return this ;
@@ -749,6 +746,15 @@ if ( $.uiBackCompat !== false ) {
749746 }
750747 } ) ;
751748 } ( jQuery , jQuery . ui . tabs . prototype ) ) ;
749+
750+ // abort method
751+ ( function ( $ , prototype ) {
752+ prototype . abort = function ( ) {
753+ if ( this . xhr ) {
754+ this . xhr . abort ( ) ;
755+ }
756+ } ;
757+ } ( jQuery , jQuery . ui . tabs . prototype ) ) ;
752758}
753759
754760} ) ( jQuery ) ;
0 commit comments