获取jQuery UI选项卡中的当前选项卡 [英] get the current tab in jQuery UI tabs
问题描述
我正在jQuery UI对话框窗口中使用jQuery UI Tabs.
I am using jQuery UI Tabs inside of the jQuery UI dialog window.
我遇到了一个实例,单击一个对话框按钮时,需要在其中找到当前选项卡的ID.查看由jQuery UI选项卡和对话框生成的HTML,我真的找不到做到这一点的方法.包含选项卡的<ul>
元素与对话框按钮组之间的距离约为3 <div>
.
I've come across an instance, where I need to find the id of the current tab when clicking on one of the dialog buttons. Looking at the HTML generated by jQuery UI tabs and dialog, I can't really find a way of doing this. The <ul>
elements that hold the tab, are about 3 <div>
's away from the group of dialog buttons.
我尝试过:
$("#DialogBox").dialog({
autoOpen: false,
modal: true,
buttons: [
{
text: "Save",
click: function () {
var currentTabId = $(this).closest("ul").attr("id");
alert(currentTabId);
但是我只是收到一个未定义"的警报.
But I just get an 'undefined' alert back.
有没有办法做到这一点?
Is there a way of doing this?
谢谢
推荐答案
根据手册 http://api.活跃的JqueryUI选项卡的jqueryui.com/tabs/吸气器是
var active = $( ".selector" ).tabs( "option", "active" );
*用您的一个代替".selector"
.
*Replace ".selector"
by your one.
然后active.attr( 'id' )
将完全返回您需要的内容.
Then active.attr( 'id' )
will return exactly what you need.
这篇关于获取jQuery UI选项卡中的当前选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!