title: Twitter bootstrap tabs and javascript events
body: <p>I am using twitter bootstrap for a project - in particular its tab functions (<a href="http://twitter.github.com/bootstrap/javascript.html#tabs" rel="noreferrer">http://twitter.github.com/bootstrap/javascript.html#tabs</a>)</p>
  
  <p>Now I have this tablist and when I press the tab it switches to the content of each individual tab. However, this content is preloaded in the page (the html code for the content of all tabs is already there, you only change the visibility by pressing the tabs).</p>
  
  <p>However I want to only dynamically load content when a certain tab is pressed, so one will get the latest data instead of the data when the whole page was loaded.</p>
  
  <p>I am planning on using jQuery for this. However, how can I make it that when a tab is pressed a certain jquery function is called?</p>
  
  <p>I tried to show an alert when a tab was clicked (if that works, a jQuery function will too), but even that isn't working: </p>
  
  <pre><code>&lt;script type="text/javascript" src="http://code.jquery.com/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="http://twitter.github.com/bootstrap/1.4.0/bootstrap-tabs.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $(function() {
      $('.tabs').bind('click', function (e) {
          e.target(window.alert("hello"))
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>And my html:</p>
  
  <pre><code>&lt;ul class="tabs" data-tabs="tabs"&gt;
    &lt;li class="active"&gt;&lt;a href="#tab1"&gt;tab 1&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="#tab2"&gt;tab 2&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;div id="my-tab-content" class="tab-content"&gt;
    &lt;div class="tab-pane" id="tab1"&gt;
        &lt;h1&gt;Tab1&lt;/h1&gt;
        &lt;p&gt;orange orange orange orange orange&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class="tab-pane" id="tab2"&gt;
       &lt;h1&gt;Tab2&lt;/h1&gt;
       &lt;p&gt;blue blue blue blue blue&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Any idea on how to make this work?</strong></p>
  
  <p>see this for the workings of twitter bootstrap tabs: (<a href="http://twitter.github.com/bootstrap/javascript.html#tabs" rel="noreferrer">http://twitter.github.com/bootstrap/javascript.html#tabs</a>)
  and the js file it uses:
  <a href="http://twitter.github.com/bootstrap/1.4.0/bootstrap-tabs.js" rel="noreferrer">http://twitter.github.com/bootstrap/1.4.0/bootstrap-tabs.js</a></p>