Permalink
Browse files

If a panel is already created and contained by the `widget.element` w…

…e don't want to move it or create a new panel.
  • Loading branch information...
1 parent a435586 commit 7767421604999b44b9ed1c550320d0f04b7f74bb @davidmurdoch committed May 11, 2011
Showing with 13 additions and 7 deletions.
  1. +13 −7 ui/jquery.ui.tabs.js
View
@@ -799,24 +799,30 @@ if ( $.uiBackCompat !== false ) {
li.addClass( "ui-state-default ui-corner-top" ).data( "destroy.tabs", true );
li.find( "a" ).attr( "aria-controls", id );
+ var doInsertAfter = index >= this.lis.length;
+
// try to find an existing element before creating a new one
var panel = this.element.find( "#" + id );
if ( !panel.length ) {
panel = this._createPanel( id );
+ if ( doInsertAfter ) {
+ if ( index > 0 ) {
+ panel.insertAfter( this.panels.eq( -1 ) );
+ } else {
+ panel.appendTo( this.element );
+ }
+ } else {
+ panel.insertBefore( this.panels[ index ] );
+ }
}
panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ).hide();
- if ( index >= this.lis.length ) {
+ if ( doInsertAfter ) {
li.appendTo( this.list );
- if( index > 0 ) {
- panel.insertAfter( this.panels.eq( -1 ) );
- } else {
- panel.appendTo( this.list[0].parentNode );
- }
} else {
li.insertBefore( this.lis[ index ] );
- panel.insertBefore( this.panels[ index ] );
}
+
options.disabled = $.map( options.disabled, function( n ) {
return n >= index ? ++n : n;
});

0 comments on commit 7767421

Please sign in to comment.