File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -775,20 +775,30 @@ if ( $.uiBackCompat !== false ) {
775775 li . addClass ( "ui-state-default ui-corner-top" ) . data ( "destroy.tabs" , true ) ;
776776 li . find ( "a" ) . attr ( "aria-controls" , id ) ;
777777
778+ var doInsertAfter = index >= this . lis . length ;
779+
778780 // try to find an existing element before creating a new one
779781 var panel = this . element . find ( "#" + id ) ;
780782 if ( ! panel . length ) {
781783 panel = this . _createPanel ( id ) ;
784+ if ( doInsertAfter ) {
785+ if ( index > 0 ) {
786+ panel . insertAfter ( this . panels . eq ( - 1 ) ) ;
787+ } else {
788+ panel . appendTo ( this . element ) ;
789+ }
790+ } else {
791+ panel . insertBefore ( this . panels [ index ] ) ;
792+ }
782793 }
783794 panel . addClass ( "ui-tabs-panel ui-widget-content ui-corner-bottom" ) . hide ( ) ;
784795
785- if ( index >= this . lis . length ) {
796+ if ( doInsertAfter ) {
786797 li . appendTo ( this . list ) ;
787- panel . appendTo ( this . list [ 0 ] . parentNode ) ;
788798 } else {
789799 li . insertBefore ( this . lis [ index ] ) ;
790- panel . insertBefore ( this . panels [ index ] ) ;
791800 }
801+
792802 options . disabled = $ . map ( options . disabled , function ( n ) {
793803 return n >= index ? ++ n : n ;
794804 } ) ;
You can’t perform that action at this time.
0 commit comments