Chris
Chris

Reputation: 2344

How to swap the position of a jquery ui tab with another ui tab using jquery?

If I create a jQuery UI tab control. I add one tab. I add a second tab. How do I switch the position of the tab?

I want to be able to create a new tab at the start of the tab buttons, so I use

$('.tabs').tabs("add","tabContent.htm","New Tab")

but this creates the tab and appends it to the end of the exisiting tab buttons, but I need it to appear at the start. How can I switch their positions using jquery?

Unsure how to remove and re-add the button before the other ones.

Upvotes: 3

Views: 545

Answers (3)

Dusty
Dusty

Reputation: 4697

I believe that there is an optional 4th parameter for the .tabs method which allows for this.

.tabs( "add" , url , label , [index] );

I think this would work.

$('.tabs').tabs("add","tabContent.htm","New Tab", 0)

Upvotes: 4

AlexC
AlexC

Reputation: 9661

$('.tabs').tabs("add","tabContent.htm","New Tab", 0)

Upvotes: 2

sadmicrowave
sadmicrowave

Reputation: 40902

I'm not quiet sure the syntax of .tabs() but it sounds like you want .prepend(). Something like this:

//assuming .tabs is the tab container
$('.tabs').prepend( $(this).tabs("add","tabContent.htm","New Tab") );

Upvotes: 0

Related Questions