jQuery: Fancybox produces a loop of errors in chrome using ajax

自作多情 提交于 2019-12-25 06:50:07

问题


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.


回答1:


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.




回答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'**
}); 


来源:https://stackoverflow.com/questions/6535803/jquery-fancybox-produces-a-loop-of-errors-in-chrome-using-ajax

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