title: Fancybox jQuery ajax on success bind form Submit
body: <p>is there a way to bind the "submit" to the fancybox after success?</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>&lt;div class="ta_l" id="tell_friend"&gt;
      &lt;form id="form_tell_friend" method="post" action=""&gt;            
          &lt;table cellspacing="0" cellpadding="0" border="0" class="tbl_insert mr_b0"&gt;
              &lt;tbody&gt;
                  &lt;tr class="tell_friend_email dn"&gt;
                      &lt;th&gt;&amp;nbsp;&lt;/th&gt;
                      &lt;td&gt;&lt;span class="red"&gt;Please provide a valid email address&lt;/span&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;th&gt;&lt;label for="tell_friend_email"&gt;Email: *&lt;/label&gt;&lt;/th&gt;
                      &lt;td&gt;&lt;input type="text" class="fld" value="" id="tell_friend_email" name="tell_friend_email" /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr class="tell_friend_content dn"&gt;
                      &lt;th&gt;&amp;nbsp;&lt;/th&gt;
                      &lt;td&gt;&lt;span class="red"&gt;Please provide a message&lt;/span&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;th&gt;&lt;label for="tell_friend_content"&gt;Message: *&lt;/label&gt;&lt;/th&gt;
                      &lt;td&gt;&lt;textarea class="tartiny" rows="" cols="" id="tell_friend_content" name="tell_friend_content"&gt;&lt;/textarea&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;th&gt;&amp;nbsp;&lt;/th&gt;
                      &lt;td&gt;
                          &lt;label class="sbm sbm_blue small" for="tell_friend_btn"&gt;
                              &lt;input type="submit" value="Send" class="btn" id="tell_friend_btn" /&gt;
                          &lt;/label&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/tbody&gt;
          &lt;/table&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>then I call fancybox and do some validation with ajax and php:</p>
  
  <pre><code>// tell a friend form
  if($('.tell-friend').length &gt; 0) {
  
      $('.tell-friend').fancybox({
          'speedIn'       :   600, 
          'speedOut'      :   200,
          'overlayShow'   :   true,
          'scrolling'     : 'no',
          'titleShow'     : false     
      });
  
      function tellAFriend() {
  
          $.ajax({
              type    : "POST",
              cache   : false,
              url     : "/message/run/tellafriend",
              data    : $(this).serializeArray(),
              dataType: "json",
              success: function(data) {
                  $("#form_tell_friend").bind("submit", tellAFriend);                 
                  if(data != 1) {
                      $.each(data, function(key, value) {
                          $('.' + value).fadeIn(500);
                      });
                      $.fancybox.resize();
                      $("#form_tell_friend").bind("submit", tellAFriend);                     
                  } else {
                      $.fancybox({
                          'scrolling'     : 'no',
                          'content'       : 'Your message has been sent successfully'
                      });
                  }                                   
              },
              error: function(data) {
                  alert('Error occured');
              }
          });
  
          return false;
      }
  
      $("#form_tell_friend").bind("submit", tellAFriend);     
  }
  </code></pre>
  
  <p>and finally my php:</p>
  
  <pre><code>public function tellafriendAction() {
  $empty = array();
  
  if(!empty($_POST)) {
      foreach($_POST as $key =&gt; $value) {
          if (empty($value)) {
              $empty[] = $key;
          }
      }
  }
  
  if(!empty($empty)) {
      echo json_encode($empty);
  } else {
      echo 1;
  }       
  </code></pre>
  
  <p>}</p>
  
  <p>Now - validation is going fine first time, but I can't resubmit the form - if I put some values to the fields it still displays warnings after I click Submit button - as if it didn't recognize the submit event.</p>
  
  <p>I've added:</p>
  
  <pre><code>$("#form_tell_friend").bind("submit", tellAFriend);
  </code></pre>
  
  <p>on success in ajax - but I don't think it's working - any idea?</p>