Skip to content

Tabs: Use standard promise methods for jqXHR #1455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demos/tabs/ajax.html
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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