views:

30

answers:

1

What's the best way to get the currently selected tab via the tab panel's id?

My tabs which presents comments looks as follows.

<a_comment_form>

<div id='#tabs'>
<ul>
<li><a href="url_to_ajax_resource" title="div1_server_index"></li>
<li><a href="url_to_ajax_resource" title="div2_server_index"></li>
</ul>
<div id='div1_server_index'>
</div>
<div id='div1_server_index'>
</div>
</div>

user submits comments and based on certain business rules the comment is inserted either into div1 or div2,

On the server side, once the comment is created, I simply call a $('#tabs').tabs('select', 'div1_server_index') to select the tab, which reloads the tab and shows the comment the user just posted.

However if is already selected the it does not load. I understand there is a load method as well, but that does not take the id of the panel it required the index, which I can not calculate from the server side, I can generate the id.

+2  A: 

try this

var selected = $("#tabs").tabs( "option", "selected" );
From.ME.to.YOU
That gives me the the selected 'index', i want the id of the selected panel.
badnaam