@@ -337,7 +337,9 @@ $.widget( "ui.tabs", {
337
337
338
338
o . selected = self . anchors . index ( el ) ;
339
339
340
- self . abort ( ) ;
340
+ if ( self . xhr ) {
341
+ self . xhr . abort ( ) ;
342
+ }
341
343
342
344
// if tab may be closed
343
345
if ( o . collapsible ) {
@@ -413,7 +415,9 @@ $.widget( "ui.tabs", {
413
415
_destroy : function ( ) {
414
416
var o = this . options ;
415
417
416
- this . abort ( ) ;
418
+ if ( this . xhr ) {
419
+ this . xhr . abort ( ) ;
420
+ }
417
421
418
422
this . element . removeClass ( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" ) ;
419
423
@@ -604,7 +608,9 @@ $.widget( "ui.tabs", {
604
608
url = $ . data ( a , "load.tabs" ) ,
605
609
eventData = self . _ui ( self . anchors [ index ] , self . panels [ index ] ) ;
606
610
607
- this . abort ( ) ;
611
+ if ( this . xhr ) {
612
+ this . xhr . abort ( ) ;
613
+ }
608
614
609
615
// not remote
610
616
if ( ! url ) {
@@ -634,6 +640,17 @@ $.widget( "ui.tabs", {
634
640
self . element . find ( self . _sanitizeSelector ( a . hash ) ) . html ( response ) ;
635
641
} )
636
642
. 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
+ }
637
654
// take care of tab labels
638
655
self . _cleanup ( ) ;
639
656
@@ -647,26 +664,6 @@ $.widget( "ui.tabs", {
647
664
return this ;
648
665
} ,
649
666
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
-
670
667
url : function ( index , url ) {
671
668
this . anchors . eq ( index ) . data ( "load.tabs" , url ) ;
672
669
return this ;
@@ -749,6 +746,15 @@ if ( $.uiBackCompat !== false ) {
749
746
}
750
747
} ) ;
751
748
} ( 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 ) ) ;
752
758
}
753
759
754
760
} ) ( jQuery ) ;
0 commit comments