jQuery static tabs via Ajax
I am adding tabs on the fly via ajax. However, I do not want the tabs to reload each time the user reselects a tab that is open.
The following is the code I use to add tabs:
function load_project(val, pname){
projects = $tabs.children('ul').text();
if(escape(projects).match(escape(pname))){ //if already loaded, repop/refocus the tab instead of a new tab.
index = find_tab(val);
$tabs.tabs('select', index);
}else{ //ajax get info and add tab.
$.get("ajax/load_project.php", {id: val},
function(data){
$('#temp').html(data);
});
$tabs.tabs("add", '#temp', pname+"\n");
tab_array.push(val);
}
}
I think this work around is not that graceful. Anyone have any other better ideas?
I am using a hidden div, #temp, to hold the data statically then I pop it to the tabs.add() function.
I just feel having to use a temp hidden div is a little absurd.