Problem removing tabs

Problem removing tabs

Hi, I'm using jquery ui and it works fine, but I have a problem closing tabs.

I create the widget with
  1. var tabs = $('#tabs').tabs();
And the dynamic ajax tabs:
  1. tabs.tabs('add', url, title);
  2. tabs.tabs('select', tabs.tabs('length') - 1);


Each tab panel has a Close link that fires this:
  1. tabs.tabs('remove', tabs.tabs('option', 'selected'));

When there are several tabs, and I remove one, the next one is selected itself, nice, but if I try to remove this tab, I have to click the link twice. Seems like it doesn't get the "focus" properly after closing a tab and open itself the next one, and I need to clickt wice.

However, if I select manually other tab after closing one and try to close it, it works properly.

Any idea?