]> source.dussan.org Git - jquery-ui.git/commitdiff
Tabs: Use standard promise methods for jqXHR
authorScott González <scott.gonzalez@gmail.com>
Mon, 23 Feb 2015 19:55:25 +0000 (14:55 -0500)
committerScott González <scott.gonzalez@gmail.com>
Tue, 24 Feb 2015 15:24:58 +0000 (10:24 -0500)
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
ui/tabs.js

index ba766dd298d7f402d6ac64ebd924b07c7c4697bf..7a486fc9635e1459031c831b9b32be959a46e6f3 100644 (file)
@@ -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." );
index 71c60761d2189c469c8b33ae1646a5e54c0b5182..8e5f0e58d178a40cc0ef51e210fd628b68225e96 100644 (file)
@@ -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 );
                                });
                }