mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
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
(cherry picked from commit c1dfb98d45
)
This commit is contained in:
parent
ddc1b32a45
commit
1c92d68c04
@ -13,7 +13,7 @@
|
|||||||
$(function() {
|
$(function() {
|
||||||
$( "#tabs" ).tabs({
|
$( "#tabs" ).tabs({
|
||||||
beforeLoad: function( event, ui ) {
|
beforeLoad: function( event, ui ) {
|
||||||
ui.jqXHR.error(function() {
|
ui.jqXHR.fail(function() {
|
||||||
ui.panel.html(
|
ui.panel.html(
|
||||||
"Couldn't load this tab. We'll try to fix this as soon as possible. " +
|
"Couldn't load this tab. We'll try to fix this as soon as possible. " +
|
||||||
"If this wouldn't be a demo." );
|
"If this wouldn't be a demo." );
|
||||||
|
29
ui/tabs.js
29
ui/tabs.js
@ -817,6 +817,18 @@ return $.widget( "ui.tabs", {
|
|||||||
eventData = {
|
eventData = {
|
||||||
tab: tab,
|
tab: tab,
|
||||||
panel: panel
|
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
|
// not remote
|
||||||
@ -834,28 +846,21 @@ return $.widget( "ui.tabs", {
|
|||||||
panel.attr( "aria-busy", "true" );
|
panel.attr( "aria-busy", "true" );
|
||||||
|
|
||||||
this.xhr
|
this.xhr
|
||||||
.success(function( response ) {
|
.done(function( response, status, jqXHR ) {
|
||||||
// support: jQuery <1.8
|
// support: jQuery <1.8
|
||||||
// http://bugs.jquery.com/ticket/11778
|
// http://bugs.jquery.com/ticket/11778
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
panel.html( response );
|
panel.html( response );
|
||||||
that._trigger( "load", event, eventData );
|
that._trigger( "load", event, eventData );
|
||||||
|
|
||||||
|
complete( jqXHR, status );
|
||||||
}, 1 );
|
}, 1 );
|
||||||
})
|
})
|
||||||
.complete(function( jqXHR, status ) {
|
.fail(function( jqXHR, status ) {
|
||||||
// support: jQuery <1.8
|
// support: jQuery <1.8
|
||||||
// http://bugs.jquery.com/ticket/11778
|
// http://bugs.jquery.com/ticket/11778
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if ( status === "abort" ) {
|
complete( jqXHR, status );
|
||||||
that.panels.stop( false, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
tab.removeClass( "ui-tabs-loading" );
|
|
||||||
panel.removeAttr( "aria-busy" );
|
|
||||||
|
|
||||||
if ( jqXHR === that.xhr ) {
|
|
||||||
delete that.xhr;
|
|
||||||
}
|
|
||||||
}, 1 );
|
}, 1 );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user