I have a function, that runs an ajax request onClick and creates a new tab, containing loaded data. It works fine, but for better user experience i'm trying load the tab after the function is done, so the user doesn't have to to click on the newly created tab.
Here's the code:
function addTab(id, name, action) {
var tabs = $( "#tabs" ).tabs();
var tabTemplate = "<li style='max-height:32px;'><a href='#"+id+"'>"+name+"</a> <span class='ui-icon ui-icon-close' onclick='removeTab()' role='presentation'>Remove Tab</span></li>";
tabs.find( ".ui-tabs-nav" ).append(tabTemplate);
$.ajax({
type: 'GET',
url: action+'?id='+id,
data: { get_param: 'value' },
dataType: "text",
success: function(data) {var j = $.parseJSON(data);
tabs.append(
//formatting json response
);
}
});
tabs.tabs( "refresh" );
$("#tabs").tabs("load", "#"+id); //this thing is not working
}