From fa26847f910ec32bf59fe6dc839e81e5dfce8247 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 10 Oct 2011 15:34:47 -0400 Subject: [PATCH] Tabs: Force ajax tabs to resolve asynchronously to avoid a bug caused by cached XHRs resolving immediately in IE. --- tests/unit/tabs/tabs_events.js | 3 ++- ui/jquery.ui.tabs.js | 30 +++++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/tests/unit/tabs/tabs_events.js b/tests/unit/tabs/tabs_events.js index 12c9bb87b..f5cde180b 100644 --- a/tests/unit/tabs/tabs_events.js +++ b/tests/unit/tabs/tabs_events.js @@ -206,7 +206,8 @@ test( "beforeLoad", function() { }); element.find( ".ui-tabs-nav a" ).eq( 3 ).click(); tabs_state( element, 0, 0, 0, 1, 0 ); - equals( panel.html(), "

testing

", "panel html after" ); + // .toLowerCase() is needed to convert

to

in old IEs + equals( panel.html().toLowerCase(), "

testing

", "panel html after" ); }); if ( $.uiBackCompat === false ) { diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index a1bf72cb1..4127ddf84 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -541,19 +541,27 @@ $.widget( "ui.tabs", { this.xhr .success(function( response ) { - panel.html( response ); - self._trigger( "load", event, eventData ); + // TODO: IE resolves cached XHRs immediately + // remove when core #10467 is fixed + setTimeout(function() { + panel.html( response ); + self._trigger( "load", event, eventData ); + }, 1 ); }) .complete(function( jqXHR, status ) { - if ( status === "abort" ) { - self.panels.stop( false, true ); - } - - self.lis.eq( index ).removeClass( "ui-tabs-loading" ); - - if ( jqXHR === self.xhr ) { - delete self.xhr; - } + // TODO: IE resolves cached XHRs immediately + // remove when core #10467 is fixed + setTimeout(function() { + if ( status === "abort" ) { + self.panels.stop( false, true ); + } + + self.lis.eq( index ).removeClass( "ui-tabs-loading" ); + + if ( jqXHR === self.xhr ) { + delete self.xhr; + } + }); }); } -- 2.39.5