Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How set default opened JQuery UI tab another than first

I have big web application using JQuery UI Tabs. In central JS file I have setted all tabs.

Using

$("#tabs").tabs;

But on one page I need to have selected another tab than first.

If I use

$("#tabs").{ selected: add });

(name of tab is #add)

Its not running, probably because Tabs are already set up.

Does anyone know how to set opened another than first tab (in default state - after loading page) if tabs are already turned on?

I hope, you will understand, my English is pretty terrible.

like image 611
yety Avatar asked Nov 30 '22 04:11

yety


1 Answers

I know this one's old, but I noticed an error in the code you have written:

$("#tabs").{ selected: add });

This should be

$("#tabs").tabs({ selected: add });

Also, selected option is deprecated as of jquery ui 1.9 as indicated here. Recommended is the active option, details here

In any case, use the index of the tab you want to open, not the href value; i.e. if you want to open the 3rd tab use

$("#tabs").tabs({ selected: 2 });

or

$("#tabs").tabs({ active: 2 });

check this fiddle

like image 126
Tiquelou Avatar answered Dec 05 '22 19:12

Tiquelou