I’m working on a project where I need to create tabs and I need to activate the last created tab.
I’m using JUI 1.9 but I can’t find documentation about it.
This is some code I use to create tabs:
function addSearchResult(title, content) {
var id = "tabs-" + tabId,
li="<li><a href='#"+id+"'>"+title+"</a><span class='ui-icon ui-icon-close'></span></li>";
tabs.find( ".ui-tabs-nav" ).append( li );
tabs.append( "<div id='" + id + "' data-index='"+indexTab+"'><p>" + content + "</p></div>" );
indexTab++;
tabs.tabs('option','active', indexTab); /*THIS IS NOT WORKING FOR ME :S */
tabs.tabs( "refresh" );
}
Ok, I haven’t tried this – but looks like there is a bug in your code. Try changing to:
}
You have a post-increment on your indexTab variable, so need to take 1 off by the looks of it when you set the current tab.