Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery UI Tabs: How do i hide a tab and its corresponding div when i close it

I have used Jquery UI Tabs, and given close option to the tabs. By default i am creating three tabs and its corresponding three divs. Now when i close a tab then the tab and its div are removed. I need to just hide the tab and div and when i click Add Tab i should just show the hidden tab and div. I am not sure how to show/hide the tab and div property.

Thanks in advance.

Jeevi

like image 568
Jeevi Avatar asked Apr 20 '10 13:04

Jeevi


People also ask

How to disable the tab in jQuery?

disable( href )Returns: jQuery (plugin only) Disables a tab. The selected tab cannot be disabled. The href of the tab to disable.

What is jquery tab?

Tabs are the set of logically grouped content that facilitates users to flip between them. Tabs save the space like accordions. Every tab must use the following set of markups to work properly. Tabs must be in an ordered <ol> or unordered <ul> list.


1 Answers

Based on the discussion at http://old.nabble.com/UI-Tabs:-How-to-hide-show-a-Tab-td19569388s27240.html the following has worked for me -

Adding the following CSS

.ui-tabs .ui-state-disabled { 
    display: none; /* disabled tabs don't show up */ 
} 

and then using the tabs disabled options in either of the following forms -

$( ".selector" ).tabs({ disabled: [1, 2] }); //when initializing the tabs
$( ".selector" ).tabs( "option", "disabled", [1, 2] ); // or setting after init

see http://jqueryui.com/demos/tabs/#option-disabled for the detailed jQuery docs

like image 79
benophobia Avatar answered Oct 02 '22 17:10

benophobia