I am using jquery ui tabs and I have a page which have tabs within tabs, and the content of the inner tabs are loaded via Ajax (by passing the URL in the href attribute of my a element). The HTML is like this:
<div class="tabs">
<ul>
<li><a href="#tabs-1">Tab 1</a></li>
<li><a href="#tabs-2">Tab 2</a></li>
<li><a href="#tabs-4">Tab 3</a></li>
</ul>
<div id="tabs-1" class="tabs">
<p>Some content for parent tabs 1</p>
<!-- Inner tabs -->
<ul>
<li><a href="ajax/content1.html">Inner Tab 1</a></li>
</ul>
</div>
<div id="tabs-2" class="tabs">
<p>Some content for parent tabs 2</p>
<!-- Inner tabs -->
<ul>
<li><a href="ajax/content2.html">Inner Tab 2</a></li>
<li><a href="ajax/content3.html">Inner Tab 3</a></li>
</ul>
</div>
<div id="tabs-3" class="tabs">
<p>Some content for parent tabs 3</p>
<!-- Inner tabs -->
<ul>
<li><a href="ajax/content4.html">Inner Tab 4</a></li>
<li><a href="ajax/content5.html">Inner Tab 5</a></li>
<li><a href="ajax/content6.html">Inner Tab 6</a></li>
</ul>
</div>
</div>
What I wanna do is 2 things:
1- Because the contents of the inner tabs are loaded via Ajax, no content is displayed yet for these tabs when the user comes to the page for the first time. So the user has to actually click to reveal the content of the inner tabs, but what I want is that when the user first comes to the page for the first time, I want the content of the default preselected inner tabs to be shown to the user (instead of some blank content)
2- I know that I can set which tabs are selected on initialization by using the selected
options of the tabs like so:
$( ".selector" ).tabs({ selected: 0 });
By doing this, I will always get the first tab selected (but that only works when we first initialize the tabs). What I want now is to ALWAYS have the first inner tab selected as the user clicks on the parent tabs. In order words, if the user clicks on Tab 1, I want the inner tab Inner Tab 1 to be selected, if the user clicks on Tab 2, I want the inner tab Inner Tab 2 to be selected, and if the user clicks on Tab 3, I want the inner tab Inner Tab 4 to be selected. I also want the content of the selected tab to be ALWAYS visible.
I hope I was clear enough in my explanation. Please somebody, help me with this.
Thank you