From 9ea6db634f392b5432e03f893cd48a9c2e15cbb5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 9 May 2011 16:04:33 -0400 Subject: [PATCH] Tabs: Only trigger tabsload on success. --- tests/unit/tabs/tabs_deprecated.js | 7 +++++-- ui/jquery.ui.tabs.js | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index 49e89b7a0..a9f1f032f 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.js @@ -156,8 +156,11 @@ asyncTest( "spinner", function() { equals( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 1, "beforeload" ); }); element.one( "tabsload", function( event, ui ) { - equals( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 0, "load" ); - start(); + // wait until after the load finishes before checking for the spinner to be removed + setTimeout(function() { + equals( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 0, "load" ); + start(); + }, 1 ); }); element.tabs( "option", "active", 2 ); }); diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 8da11367e..e7d4e3513 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -621,6 +621,7 @@ $.widget( "ui.tabs", { this.xhr .success(function( response ) { panel.html( response ); + self._trigger( "load", event, eventData ); }) .complete(function( jqXHR, status ) { if ( status === "abort" ) { @@ -631,13 +632,11 @@ $.widget( "ui.tabs", { // "tabs" queue must not contain more than two elements, // which are the callbacks for the latest clicked tab... self.element.queue( "tabs", self.element.queue( "tabs" ).splice( -2, 2 ) ); - - delete this.xhr; } self.lis.eq( index ).removeClass( "ui-tabs-loading" ); - self._trigger( "load", event, eventData ); + delete self.xhr; }); } -- 2.39.5