Skip to content

Commit

Permalink
Tabs: Use standard promise methods for jqXHR
Browse files Browse the repository at this point in the history
The old success(), error() and complete() methods have been deprecated for a
while and have been removed in upstream master.

Closes gh-1455
  • Loading branch information
scottgonzalez committed Feb 24, 2015
1 parent 962e05d commit c1dfb98
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion demos/tabs/ajax.html
Expand Up @@ -13,7 +13,7 @@
$(function() {
$( "#tabs" ).tabs({
beforeLoad: function( event, ui ) {
ui.jqXHR.error(function() {
ui.jqXHR.fail(function() {
ui.panel.html(
"Couldn't load this tab. We'll try to fix this as soon as possible. " +
"If this wouldn't be a demo." );
Expand Down
29 changes: 17 additions & 12 deletions ui/tabs.js
Expand Up @@ -818,6 +818,18 @@ return $.widget( "ui.tabs", {
eventData = {
tab: tab,
panel: panel
},
complete = function( jqXHR, status ) {
if ( status === "abort" ) {
that.panels.stop( false, true );
}

tab.removeClass( "ui-tabs-loading" );
panel.removeAttr( "aria-busy" );

if ( jqXHR === that.xhr ) {
delete that.xhr;
}
};

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

this.xhr
.success(function( response ) {
.done(function( response, status, jqXHR ) {
// support: jQuery <1.8
// http://bugs.jquery.com/ticket/11778
setTimeout(function() {
panel.html( response );
that._trigger( "load", event, eventData );

complete( jqXHR, status );
}, 1 );
})
.complete(function( jqXHR, status ) {
.fail(function( jqXHR, status ) {
// support: jQuery <1.8
// http://bugs.jquery.com/ticket/11778
setTimeout(function() {
if ( status === "abort" ) {
that.panels.stop( false, true );
}

tab.removeClass( "ui-tabs-loading" );
panel.removeAttr( "aria-busy" );

if ( jqXHR === that.xhr ) {
delete that.xhr;
}
complete( jqXHR, status );
}, 1 );
});
}
Expand Down

0 comments on commit c1dfb98

Please sign in to comment.