aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.tabs.js
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2012-08-30 22:57:37 +0200
committerFelix Nagel <info@felixnagel.com>2012-08-30 22:57:37 +0200
commitdaadc84416d22eca651c85627d5dd683d7727d3e (patch)
treec52b8c3e89336d4d91e5a4aac8c298d472312c7a /ui/jquery.ui.tabs.js
parentc1799024684780995ba666aa1c9acfa34c69f12a (diff)
parentdec9c54632be191947c310b402810cf6f1b4250a (diff)
downloadjquery-ui-daadc84416d22eca651c85627d5dd683d7727d3e.tar.gz
jquery-ui-daadc84416d22eca651c85627d5dd683d7727d3e.zip
Merge branch 'master' into selectmenu
Diffstat (limited to 'ui/jquery.ui.tabs.js')
-rw-r--r--ui/jquery.ui.tabs.js55
1 files changed, 34 insertions, 21 deletions
diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js
index b31ce364a..7631366d6 100644
--- a/ui/jquery.ui.tabs.js
+++ b/ui/jquery.ui.tabs.js
@@ -792,13 +792,7 @@ $.widget( "ui.tabs", {
return;
}
- this.xhr = $.ajax({
- url: anchor.attr( "href" ),
- beforeSend: function( jqXHR, settings ) {
- return that._trigger( "beforeLoad", event,
- $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
- }
- });
+ this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
// support: jQuery <1.8
// jQuery <1.8 returns false if the request is canceled in beforeSend,
@@ -835,6 +829,18 @@ $.widget( "ui.tabs", {
}
},
+ // TODO: Remove this function in 1.10 when ajaxOptions is removed
+ _ajaxSettings: function( anchor, event, eventData ) {
+ var that = this;
+ return {
+ url: anchor.attr( "href" ),
+ beforeSend: function( jqXHR, settings ) {
+ return that._trigger( "beforeLoad", event,
+ $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
+ }
+ };
+ },
+
_getPanelForTab: function( tab ) {
var id = $( tab ).attr( "aria-controls" );
return this.element.find( this._sanitizeSelector( "#" + id ) );
@@ -860,6 +866,7 @@ if ( $.uiBackCompat !== false ) {
}
});
+ // TODO: Remove _ajaxSettings() method when removing this extension
// ajaxOptions and cache options
$.widget( "ui.tabs", $.ui.tabs, {
options: {
@@ -879,19 +886,6 @@ if ( $.uiBackCompat !== false ) {
return;
}
- $.extend( ui.ajaxSettings, that.options.ajaxOptions, {
- error: function( xhr, s, e ) {
- try {
- // Passing index avoid a race condition when this method is
- // called after the user has selected another tab.
- // Pass the anchor that initiated this request allows
- // loadError to manipulate the tab content panel via $(a.hash)
- that.options.ajaxOptions.error( xhr, s, ui.tab.closest( "li" ).index(), ui.tab[ 0 ] );
- }
- catch ( e ) {}
- }
- });
-
ui.jqXHR.success(function() {
if ( that.options.cache ) {
$.data( ui.tab[ 0 ], "cache.tabs", true );
@@ -900,6 +894,23 @@ if ( $.uiBackCompat !== false ) {
}});
},
+ _ajaxSettings: function( anchor, event, ui ) {
+ var ajaxOptions = this.options.ajaxOptions;
+ return $.extend( {}, ajaxOptions, {
+ error: function( xhr, s, e ) {
+ try {
+ // Passing index avoid a race condition when this method is
+ // called after the user has selected another tab.
+ // Pass the anchor that initiated this request allows
+ // loadError to manipulate the tab content panel via $(a.hash)
+ ajaxOptions.error(
+ xhr, s, ui.tab.closest( "li" ).index(), ui.tab[ 0 ] );
+ }
+ catch ( e ) {}
+ }
+ }, this._superApply( arguments ) );
+ },
+
_setOption: function( key, value ) {
// reset cache if switching from cached to not cached
if ( key === "cache" && value === false ) {
@@ -937,7 +948,9 @@ if ( $.uiBackCompat !== false ) {
this._super();
this._on({
tabsbeforeload: function( event, ui ) {
- if ( !this.options.spinner ) {
+ // Don't react to nested tabs or tabs that don't use a spinner
+ if ( event.target !== this.element[ 0 ] ||
+ !this.options.spinner ) {
return;
}