views:

409

answers:

2

I'm completely puzzled, I make an ajax call inside a Jquery UI Tab, after that I want to refresh the content of the tab, the function that should be doing it is:

function reloadTab(){
var $tabs = $('#tabs').tabs();
var selected = $tabs.tabs('option', 'selected');
$tabs.tabs('load', selected);
return false; 
}

Incredible but true it doesn't work at all, since this:

$tabs.tabs('select', selected);

Wouldn't work either I thought it was an issue with not being able to reload a tab, and this is what I found out:

'select' works only to select a different tab than the current one while load doesn't work at all.

I also tried the solution posted here: http://stackoverflow.com/questions/900821/stuck-reloading-ajax-content-in-a-jquery-tab-programatically

With no luck.. please help me because I'm starting to get angry :-(

+1  A: 

Hi,

could you please clarify: Does selected contain the expected value, i.e. does

$tabs.tabs('option', 'selected')

produce the correct index? If it does, then tabs('load') appears to be buggy (as suggested in the post you mentioned). Maybe you could try switching to another tab, do the load, then switch back again. Not very elegant, I know. Sorry I can't be of more help.

Cheers, Tom

Tom Bartel
Yes, it contains the expected value (2) I also tried to call it like this: $tabs.tabs('load',2); with no luck.I finally given up and made a 'manual' ajax call to reload the page. The tabs part of jquery is surprisingly buggy.Thank you anyway :-)
0plus1
Yeah, sorry it didn't work out.
Tom Bartel
+1  A: 

Hi, This works for me:

function reloadTab(tabnum) {
 $('#tabs').tabs('select',tabnum);
 $('#tabs').tabs('load',tabnum);
}

The trick is that load does not work if there hasn't been a tab selected first.

jafmaw