0

This my code:

<a href="url" class="fancybox">Text</a>
jQuery(document).ready(function() {
    jQuery(".fancybox").fancybox({
        'overlayShow': true,
        'hideOnContentClick': false
    });
});

The box is displayed, the content is loaded but in the error console of chrome "Uncaught TypeError: Cannot call method 'width' of undefined".

The box can be closed but then it is not possible to open it again.

I am using FB 1.3.4 and jQuery 1.5.1.

timopeschka
  • 401
  • 3
  • 8
  • 16

2 Answers2

4

Ive had this same problem before and the cause was that I was loading the fancybox.1.3.4.js file inside of the file that was getting loaded by fancybox in the first place.

If you are doing this as well, it will be the problem. Otherwise I do not know.

anson
  • 4,156
  • 2
  • 22
  • 30
  • Very usefull answer, THX :D. As I was calling a rails action with AJAX, it was reloading the application.html.erb which was calling another time jquery.fancybox-1.3.4.pack. – Bachet Oct 16 '11 at 19:45
  • Thanks for pointing in the right direction. I was facing a similar issue but mine was duplicate jquery. Thanks – Himanshu Jul 07 '12 at 13:43
2

Problem is caused by your code where you did not mention of using iframe.

You will have to declare like this:

$('a[rel^=iframe_group]').fancybox({
    'autoDimensions'    : false,
    'autoScale'     : false,    
    'width'         : '50%',
    'height'        : '80%',
    'transitionIn'      : 'none',
    'transitionOut'     : 'none',
    **'type'            : 'iframe'**
}); 
sfsiu2001
  • 31
  • 1
  • Thank you very much to post this answer. I have faced the same issue and eventually resolved by your answer. – VenkatK Jun 12 '13 at 12:23