Running jQuery code on tab select, doesn't work for 1st tab on page load

Running jQuery code on tab select, doesn't work for 1st tab on page load


Hi guys
I posted on here a few days ago about wanting to run some JS when a
tab is selected. But the code I'm using only works when the tab is
changed.
// TABS BAR
$('#tabs').tabs({
select: function(event, ui) {
switch (ui.index) {
case 0:
// CONTACTS TAB
$('#contacts_grid').flexigrid();
break;
case 4:
// INVOICES TAB
$('#invoices_grid').flexigrid();
break;
}
}
});
When the page loads, the 1st tab is selected but the jQuery call to
flexigrid in case 0 above obviously doesn't fire.
Also I have implemented the cookie feature to remember the last
selected tab, so the initial tab when the page loads won't necessarily
be 0
Any ideas on how to solve this?
I'm new to jQuery and having a very hard time in figuring this stuff
out, only used to basic JS like form validation etc.
Thanks, B