title: In jquery-ui 1.9, how do you create new tabs dynamically?
body: <p>According to the upgrade guide for jquery-ui 1.9 tabs - <a href="http://jqueryui.com/upgrade-guide/1.9/#deprecated-add-and-remove-methods-and-events-use-refresh-method">http://jqueryui.com/upgrade-guide/1.9/#deprecated-add-and-remove-methods-and-events-use-refresh-method</a> - when adding new tabs dynamically, you only have to do something like this:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div id='tabs'&gt;
      &lt;ul&gt;
          &lt;li&gt;&lt;a href='#tab1'&gt;#1&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;div id='tab1'&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;button id='add-tab'&gt;Add tab&lt;/button&gt;
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre><code>$(document).ready(function() {
      $("div#tabs").tabs();
  
      $("button#add-tab").click(function() {
  
          var num_tabs = $("div#tabs ul li").length + 1;
  
          $("div#tabs ul").append(
              "&lt;li&gt;&lt;a href='#tab" + num_tabs + "'&gt;#" + num_tabs + "&lt;/a&gt;&lt;/li&gt;"
          );
  
          $("div#tabs").tabs("refresh");
      });                    
  });
  </code></pre>
  
  <p>However when I try change between the newly created tabs, I get the following error in firebug: </p>
  
  <blockquote>
    <p>jQuery UI Tabs: Mismatching fragment identifier.</p>
  </blockquote>
  
  <p>If I understand correctly, this error means that the actual tab panel isn't being created (and thus there's a mismatch between the nav panel and the tab panel). But the upgrade guide makes no mention of creating a tab panel.</p>
  
  <p>So I'm assuming that either I'm doing it wrong or that the upgrade guide is incomplete. Please clarify.</p>
  
  <p>Interestingly enough, when removing tabs, the upgrade guide says you have to explicitly remove both the list item from the nav panel as well as the tab panel explicitly, so I'm wondering if the same applies to adding tabs.</p>