forms plugin inside tab

forms plugin inside tab

I want to use jquery forms but my form is in a tab which is loaded dynamically by ajax.  I am not sure where/when/how to enable the form.  I think I need to put the enabling call {$('#myForm').ajaxForm} somewhere so it can be called after the tab containing the form is loaded, but I don't know how.  Can someone help?  Thanks.

         --Len


My html code is below.  I have an external file which contains the same form (different id) in the third tab.  The second tabs submission is intercepted; the external, not surprisingly is not intercepted.  I don't know where to put the call so the dynamically loaded form's submission is also intercepted.  Thanks.

  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
 
    <script> 
        // wait for the DOM to be loaded 
        $(document).ready(function() { 
            // bind 'myForm' and provide a simple callback function 
            $('#myForm').ajaxForm(function() { 
                alert("Thank you for your comment!"); 
            }); 
        }); 
    </script> 

</head>
<body>
 
<div id="tabs">
  <ul>
    <li><a href="#fragment-1"><span>One</span></a></li>
    <li><a href="#fragment-3"><span>Three</span></a></li>
    <li><a href="ex1-ext.html"><span>External</span></a></li>
  </ul>
  <div id="fragment-1">
    <p>First tab is active by default:</p>
    <pre><code>$( "#tabs" ).tabs(); </code></pre>
  </div>
  <div id="fragment-3">
<form id="myForm" action="comment.php" method="post"> 
    Name: <input type="text" name="name" /> 
    Comment: <textarea name="comment"></textarea> 
    <input type="submit" value="Submit Comment" /> 
</form>



 </div>
</div>
 
<script>
$( "#tabs" ).tabs();
</script>

</body> </html>