jquery - colorbox doesn't close after sumbit form -


i have issues colorbox if try submit form, colorbox remains opened on success. tried add colorbox.close(); on success, worked, if try click link again open form, form not displaying - can see close button , overlay. tried hide form , overlay after success, again - form didn't open on second click.

i tried tweek js file - assign same functionality submit button close button has, of course didn't work properly. how make form close on submit - please suggest.

the popup form:

<div class="body" id="inline-popup">     <form action="index" method="post" id="form">         <fieldset>             <label>name</label>             <input type="text" id="name" name="name" />         </fieldset>          <fieldset>             <label>url (optional)</label>             <input type="text" name="url" id="url" />         </fieldset>         <fieldset>             <input type="submit" value="ok" class="submit" />         </fieldset>     </form> </div> 

colorbox call , ajax:

    <script>         $(".popup").colorbox({inline:true, width:"300px", height:"100%"});  $('.submit').on('click', function(e){          $.ajax({             type: "post",             url: '/pathname/submitform',             data: $("#form").serialize(),             error: function(xhr, ajaxoptions, thrownerror, data) {                 err = array();                 err[0] = "oops error occured";                     console.log(err);             },             datatype: "json",             success:  function(data) {                 if(data.success=="yes") {                     console.log(data.success);                  } else {                     console.log(data.error);                 }             }         });         e.preventdefault();     });     </script> 

try this:

success:  function(data) {     if(data.success=="yes") {         $.fn.colorbox.close();         console.log(data.success);     } 

Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -