Retrieving the currently selected tab index

Retrieving the currently selected tab index

Hi,

I came across what seems to be bug in the jquery tabs UI widget. When I use the following code

$(function(){
              // Load the Tabs
                  $('#tabs').tabs({
                         select:function(event,ui) { //bind click event to link
                              selectedIndex=$('#tabs').tabs().tabs('option', 'selected');
                              alert('You chose tab index '+ selectedIndex');
                              }
                      });  
The alert box doesn't display the current tab index that I select but rather it displays the index of the previously selected tab. For example, let's say I have 3 tabs: the first one starts with index 0 and the last one end with index 2. If I  select tab 2 after tab 3 the alertbox  displays  You chose  tab index 2 (instead of tab index 1 which is the index for the second tab). Is there another way to retrieve the currently selected tab or is this a bug in the tabs ui tool?