jQuery选项卡已选择 [英] jquery tab selected
问题描述
通过标签面板的ID获取当前选定标签的最佳方法是什么?
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>
用户提交评论,并根据某些业务规则将评论插入到div1或div2中,
user submits comments and based on certain business rules the comment is inserted either into div1 or div2,
在服务器端,创建注释后,我只需调用$('#tabs').tabs('select','div1_server_index')选择选项卡,该选项卡将重新加载选项卡并显示注释用户刚刚发布.
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.
但是,如果已经选择,则不会加载.我知道也有一个加载方法,但是它不使用它需要索引的面板的ID,我无法从服务器端计算出该ID,因此可以生成ID.
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.
推荐答案
尝试一下
var selected = $("#tabs").tabs( "option", "selected" );
这篇关于jQuery选项卡已选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!