get the current tab in jQuery UI tabs

jquery, jquery-ui, jquery-ui-dialog, jquery-ui-tabs

Solution

According to manual http://api.jqueryui.com/tabs/ getter of active JqueryUI tab is

var active = $( ".selector" ).tabs( "option", "active" );

*Replace `".selector"` by your one.

Then `active.attr( 'id' )` will return exactly what you need.

Problem

I am using jQuery UI Tabs inside of the jQuery UI dialog window. 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. I tried: ``` $("#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? Thanks

Original source