0

I use Fancybox 2.1.5 for opening popup window with user form. So i use next code:

<script type="text/javascript">
$("a.fancybox").fancybox({
 type: 'iframe',
 fitToView: false,
 autoSize: true,
 autoResize: true,  
});
</script>

This script opens enroll.php where form is included. Button in this form has code:

<form ... action="enrollsend.php">
<input type="submit" onclick="parent.$.fancybox.update();">

And the problem is that size of both windows (after submitting button next page in fancybox appears) don't change at all. I want fancybox size to be automate, but don't know why it doesn't work.

Bullwinkle
  • 59
  • 1
  • 1
  • 10
  • Try `
    ` instead.
    – JFK May 06 '14 at 19:52
  • JFK, thank you for you answer, but it doesn't work. – Bullwinkle May 07 '14 at 14:07
  • my bad, try `onsubmit="javascript:parent.jQuery.fancybox.update();"` – JFK May 07 '14 at 15:10
  • JFK, i found your other great answer [here](http://stackoverflow.com/questions/10996212/auto-height-resizing-in-fancybox) and somehow after submitting button height of fancybox being resized only by height to fit the content, but not width. I also included beforeShow function you adviced, it works for the first popup, but not for the second (when new content being opened after form submitting in the same popup). In manual i found that $.fancybox.update() "Auto-sizes fancyBox height to match height of content". So is there any way to resize popup after conent updating not only by height? – Bullwinkle May 07 '14 at 16:06
  • You can check my demo [here](http://www.sundayrock.ru/schedule/raspisanie_user.php?city=1), just try any link from right column. – Bullwinkle May 07 '14 at 16:07
  • It seems i almost fix it. To resize popup after updating something like this can be used. I not fully understand how it works, but in case of static width and height you can just set manually with onupdate function.: `onUpdate: function(){ this.width = $('.fancybox-iframe').contents().find('html').width(); this.height = $('.fancybox-iframe').contents().find('html').height(); }` – Bullwinkle May 07 '14 at 16:42
  • JFK, anyway i catch this idea because of your explanation i linked recent, so many thanks for you. I will be happy in case you tell me how to avoid putting static width and height into onupdate function and get width and height from for example `` – Bullwinkle May 07 '14 at 16:46

0 Answers0