This is a custom effect for jQuery tools that enable caching for ajaxed tabs. Please advice on anything that I can improve. Note that I'm not sure where to put the loading indicator, so, at least have a look at that. Thanks.
$.tools.tabs.addEffect("ajax_cache", function(tabIndex, done) {
//check if content already loaded
//if yes, display it, and hide the rest
//if no, send ajax request
var panes_cont = this.getPanes().eq(0);
var dest_pane = panes_cont.find("#tabindex_"+tabIndex);
if(dest_pane.length > 0){
panes_cont.children().hide();
dest_pane.show();
} else {
panes_cont.children().hide();
panes_cont.append("<img id='tab_loading' src='/graphics/loading.gif' />");
var new_pane = $('<div>').attr('id', 'tabindex_'+tabIndex).load(this.getTabs().eq(tabIndex).attr("href"),
function(){
panes_cont.find("#tab_loading").remove();
panes_cont.append(new_pane.show());
});
}
done.call();
});