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
According to manual http://api.jqueryui.com/tabs/ getter of active JqueryUI tab is
*Replace
".selector"
by your one.Then
active.attr( 'id' )
will return exactly what you need.⚡ worked for me this way ⚡
This is what worked for me (jQuery 1.9, jQueryUI 1.10). I have not tested this for earlier versions of jQueryUI, but if you have jQueryUI 1.8 or earlier, instead of 'active' try using 'select'.
//for getting selected tabs
var tabs = $("#tabs").children().find(".current").attr('href');
here is the correct one and the simplest:
You should add active selector next to tab-pane. This will return the current active tab ID.
What worked for me was: