1

I have problem with close my fancybox after submit registration form in my web. I using cms pro system....

With this I showing fancybox include form:

submitHandler: function(form) {
    var str = $("#subscriber_application").serialize(); 
      $.ajax({
          type: "POST",
          url: "ajax/user.php",
          data: str,
         success: function (msg){
                $("div#subscriber_response").html(msg);
                $("#subscriber_application").hide();
            }
          });
}

My html:

<div id="divForm" style="display:none;min-height: 400px;">
<div class="fr" style="min-height: 400px;">        
        <div>
          <div style="position:relative">
               <div id="msgholder"></div>
          </div>
        <form action="" method="post" id="admin_form" name="admin_form">
          <input name="email" type="text" size="45" maxlength="40" class="home_input"   placeholder="Email Address" />
          <input name="token" type="text" size="45" maxlength="40" class="home_input"   placeholder="Token" />
          <input name="submit" value="&nbsp;" type="submit" class="account_activate"/>
        </form>
      <?php echo $core->doForm("accActivate","ajax/user.php");?>
      </div>


<div style="width:800px;"></div>

<h1>Subscribe For Free Application</h1>
<hr />
<p>&nbsp</p>
<div class="registracia">
  <div id="subscriber_response" class="msgErrors"></div>
  <div id="post_your_requirement_success" ></div>
  <form action=""  method="post" id="subscriber_application" name="subscriber_application" style="width:270px;">
    <p>
      <input data-progression="" type="text" data-helper="Username should be at least 3 characters long" name="username" value="" class="home_input" placeholder="User name" name="username" />
    </p>
    <p>
      <input data-progression="" type="text" data-helper="Add your E-mail" name="email" class="home_input"   placeholder="Email address" value="<?php if(isset($_SESSION['subscriber_application']['email_address'])):echo $_SESSION['subscriber_application']['email_address'];endif; ?>" />
    </p>
    <p>
      <input data-progression="" type="text" data-helper="Your Restaurant Name" name="hotel_name" class="home_input"   placeholder="Restaurant name" />
    </p>
    <p>
      <input data-progression="" type="password" data-helper="Add Password - min 4 characters" name="password" class="home_input" placeholder="Password" />
    </p>
    <p>
      <!---  <input tabindex="13" type="checkbox" id="flat-checkbox-1"  />I agree, I've read <a href="#">terms of use</a> -->
    </p>
      <input name="submit" type="submit"  id="submit" value="&nbsp;" class="sign_in" />
      <input name="doapplication" type="hidden" value="1" />    
    </form>
</div>
<div style="social">
<h2>Sign in with social network!</h2>
<ul>
    <li style="list-style:none"><img src="../demo/theme/master/images/g+.jpg" /></li>
    <li style="list-style:none"><img src="../demo/theme/master/images/faceb.jpg" /></li> 
</ul>
</div>

my button :

<a href="#divForm" id="btnForm">
      <button type="button" class="way-start" style="border-radius: 5px;height: 60px;width: 180px;background-color: green;border: 1px solid green;font-size: 26px;font-weight: 300;font-family: Helvetica Neue, Helvetica, Sans Serif;">Get the app!</button>
</a>

I will be grateful for every opinion !!! Thanks!!!

6
  • could you show the html for #btnForm? I think you don't really need to apply css styles within onStart and onClosed. On the other hand, if you close fancybox after form submission, you won't be able to see the "thank you" message unless you set a delay (setTimeout) or add a button to manually close fancybox: what would you like to do?
    – JFK
    Nov 3, 2013 at 21:33
  • Hello JFK Thanks for help.... I have edited code. First I wanted add delay for close...or have you better idea ?
    – Makromat
    Nov 3, 2013 at 21:40
  • I shouldn't be debugging your code but if you bind a click to an element like $("#submitemail").click(), at least an element with id="submitemail" should exist and I don't see any in your code (neither I see any id="btnForm"). BTW, the php code is not relevant within the context of your question. Please post only the rendered html.
    – JFK
    Nov 3, 2013 at 21:47
  • Better now ? Thanks again !
    – Makromat
    Nov 3, 2013 at 21:56
  • 1
    what about $("#submitemail").click()?
    – JFK
    Nov 3, 2013 at 23:57

2 Answers 2

0

My solution is in success function like:

setTimeout("$.fancybox.close()", 5000);
-1

Try triggering a click on the fancybox close button.

$('#fancybox-close').trigger('click');
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.