Fancybox - form submit and close it?

一笑奈何 提交于 2019-12-23 03:56:11

问题


I start my fancybox like code down

$('a.detail').click(function() {
   $.fancybox({
         'width'         : 750,
         'height'        : 520,
         'title'         : 'EDIÇÃO DE SHOW',
   'titlePosition' : 'inside',
   'transitionIn' : 'fade',
   'transitionOut' : 'none',
   'href'          : 'templates/detail.php?id=<?php echo $tg_id['id'];?>',
   'type'          : 'iframe'  
   })
  })

and into myfancy, I got a form to update informations about schedules.

$(function() {

   $("form#comment").submit(function() {

   var dat = $("#datepicker").val();
   var uf = $("#uf").val();
   var flr = $("input[name='flpic']:checked").val();
   var tit = $("#titulo").val();
   var mssg = $("#mensagem").val();
   var id = $("#id").val();

   if(BrowserDetect.browser == 'Explorer'){
    var nav = 'ie'
   } else {
    var nav = 'ot'
   }

   $.ajax({

             type: "POST",
             url: "edit_agenda.php",
             data: "id="+id+"&datepicker="+ dat+"&uf="+uf+"&fl="+flr+"&titulo="+tit+"&mensagem="+mssg+"&bro="+nav,
             success: function(){

      $("#status").html("<img src='../images/1-0.gif' alt='Enviando' />");

   **???? Can I call some function to close this fancy here?**   

              }

         });

      return false;

  });

 });

My question is:

After submit this form, can I close this fancy within a function?


回答1:


You can close it with $.fancybox.close(). Mind reading the API.




回答2:


$.ajax({
    type: "POST",
    url: "edit_agenda.php",
    data: "id="+id+"&datepicker="+ dat+"&uf="+uf+"&fl="+flr+"&titulo="+tit+"&mensagem="+mssg+"&bro="+nav,
    success: function(){
    parent.$.fancybox.close();
    }
});



回答3:


Within an iframe

<input name="submit" type="submit" value="close" onClick="$.fancybox.close();" />

will also work.




回答4:


Use parent.$.fancybox.close(); within the Iframe.




回答5:


use this below script:

parent.jQuery.fancybox.close();



回答6:


Try a PHP solution could try a simple rewrite in javascript if you want.

<?php
$close = 1;
if( $close) { echo ' <body onunload="self.close()"> ' ;} 
?>


来源:https://stackoverflow.com/questions/4758964/fancybox-form-submit-and-close-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!