JQuery UI tabs notgetting selected

JQuery UI tabs notgetting selected

Hi,

I'm trying to add a new tab dynamically to the JQuery-UI tab. The problem is that the newly created tab is not getting selected automatically.

I want the newly added tab to be selected automatically. How to fix the problem?

This is my code:
  1. $(document).ready(function(){
  2.    
  3.     var tabs = $("#container-1").tabs();
  4.     $('#add_tab').click( function(){
  5.             var ul = tabs.find( "ul" );
  6.             $( "<li><a href='#newtab'>New Tab</a></li>" ).appendTo( ul );
  7.             $( "<div id='newtab'>Name :<input type='text'></input></div>" ).appendTo( tabs );
  8.             tabs.tabs( "refresh" );
  9.             tabs.tabs("select", 1);
  10.         });
  11. });