From: Scott González Date: Mon, 23 Feb 2015 19:55:25 +0000 (-0500) Subject: Tabs: Use standard promise methods for jqXHR X-Git-Tag: 1.12.0-beta.1~435 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c1dfb98d4576901aacf35f99d2506e8f652c2690;p=jquery-ui.git 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 --- diff --git a/demos/tabs/ajax.html b/demos/tabs/ajax.html index ba766dd29..7a486fc96 100644 --- a/demos/tabs/ajax.html +++ b/demos/tabs/ajax.html @@ -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." ); diff --git a/ui/tabs.js b/ui/tabs.js index 71c60761d..8e5f0e58d 100644 --- a/ui/tabs.js +++ b/ui/tabs.js @@ -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 @@ -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 ); }); }