mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Tabs: When adding a new tab with an existing panel, don't move it. Fixes #4578 - adding tab moves targeted panel.
This commit is contained in:
parent
db3d1945b8
commit
965cb7359e
16
ui/jquery.ui.tabs.js
vendored
16
ui/jquery.ui.tabs.js
vendored
@ -775,20 +775,30 @@ if ( $.uiBackCompat !== false ) {
|
|||||||
li.addClass( "ui-state-default ui-corner-top" ).data( "destroy.tabs", true );
|
li.addClass( "ui-state-default ui-corner-top" ).data( "destroy.tabs", true );
|
||||||
li.find( "a" ).attr( "aria-controls", id );
|
li.find( "a" ).attr( "aria-controls", id );
|
||||||
|
|
||||||
|
var doInsertAfter = index >= this.lis.length;
|
||||||
|
|
||||||
// try to find an existing element before creating a new one
|
// try to find an existing element before creating a new one
|
||||||
var panel = this.element.find( "#" + id );
|
var panel = this.element.find( "#" + id );
|
||||||
if ( !panel.length ) {
|
if ( !panel.length ) {
|
||||||
panel = this._createPanel( id );
|
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();
|
panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ).hide();
|
||||||
|
|
||||||
if ( index >= this.lis.length ) {
|
if ( doInsertAfter ) {
|
||||||
li.appendTo( this.list );
|
li.appendTo( this.list );
|
||||||
panel.appendTo( this.list[ 0 ].parentNode );
|
|
||||||
} else {
|
} else {
|
||||||
li.insertBefore( this.lis[ index ] );
|
li.insertBefore( this.lis[ index ] );
|
||||||
panel.insertBefore( this.panels[ index ] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
options.disabled = $.map( options.disabled, function( n ) {
|
options.disabled = $.map( options.disabled, function( n ) {
|
||||||
return n >= index ? ++n : n;
|
return n >= index ? ++n : n;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user