Skip to content

Commit c1dfb98

Browse files
committed
Tabs: Use standard promise methods for jqXHR
The old success(), error() and complete() methods have been deprecated for a while and have been removed in upstream master. Closes gh-1455
1 parent 962e05d commit c1dfb98

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

demos/tabs/ajax.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
$(function() {
1414
$( "#tabs" ).tabs({
1515
beforeLoad: function( event, ui ) {
16-
ui.jqXHR.error(function() {
16+
ui.jqXHR.fail(function() {
1717
ui.panel.html(
1818
"Couldn't load this tab. We'll try to fix this as soon as possible. " +
1919
"If this wouldn't be a demo." );

ui/tabs.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,18 @@ return $.widget( "ui.tabs", {
818818
eventData = {
819819
tab: tab,
820820
panel: panel
821+
},
822+
complete = function( jqXHR, status ) {
823+
if ( status === "abort" ) {
824+
that.panels.stop( false, true );
825+
}
826+
827+
tab.removeClass( "ui-tabs-loading" );
828+
panel.removeAttr( "aria-busy" );
829+
830+
if ( jqXHR === that.xhr ) {
831+
delete that.xhr;
832+
}
821833
};
822834

823835
// not remote
@@ -835,28 +847,21 @@ return $.widget( "ui.tabs", {
835847
panel.attr( "aria-busy", "true" );
836848

837849
this.xhr
838-
.success(function( response ) {
850+
.done(function( response, status, jqXHR ) {
839851
// support: jQuery <1.8
840852
// http://bugs.jquery.com/ticket/11778
841853
setTimeout(function() {
842854
panel.html( response );
843855
that._trigger( "load", event, eventData );
856+
857+
complete( jqXHR, status );
844858
}, 1 );
845859
})
846-
.complete(function( jqXHR, status ) {
860+
.fail(function( jqXHR, status ) {
847861
// support: jQuery <1.8
848862
// http://bugs.jquery.com/ticket/11778
849863
setTimeout(function() {
850-
if ( status === "abort" ) {
851-
that.panels.stop( false, true );
852-
}
853-
854-
tab.removeClass( "ui-tabs-loading" );
855-
panel.removeAttr( "aria-busy" );
856-
857-
if ( jqXHR === that.xhr ) {
858-
delete that.xhr;
859-
}
864+
complete( jqXHR, status );
860865
}, 1 );
861866
});
862867
}

0 commit comments

Comments
 (0)