From c1dfb98d4576901aacf35f99d2506e8f652c2690 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 23 Feb 2015 14:55:25 -0500 Subject: [PATCH] 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 --- demos/tabs/ajax.html | 2 +- ui/tabs.js | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) 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 ); }); } -- 2.39.5