1

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
  • How is it that this is working correctly? Fancybox does not display automatically when you call .fancybox, so I feel like you must have some other code that you're not showing?
    – Dobler
    Commented Jun 26, 2011 at 23:18

6 Answers 6

2

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

2
  • The point is, my fancybox doesn´t close. Becouse it is inside a iframe.
    – Klauzito
    Commented Jan 21, 2011 at 17:08
  • 3
    "Within an iframe use - parent.$.fancybox.close();" Commented Jan 22, 2011 at 3:50
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();
    }
});
1
  • Can you add a description as to how this code addresses the issue.
    – Ren
    Commented Mar 27, 2013 at 15:12
0

Within an iframe

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

will also work.

0

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

0

use this below script:

parent.jQuery.fancybox.close();
0
-1

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

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

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.