-1

I have the error

Uncaught TypeError: Object # has no method 'fancybox'

in my JS console on this website http://www.e-fashion-awards.com/

As you can see, I include jquery.fancybox.js after jquery.min.js and I include jquery only once (saw in other topics).

Here is the piece of buggy code including the js files includes and the fancybox call :

<link rel='stylesheet' id='fancybox-css'  href='http://www.e-fashion-awards.com/wordpress/wp-content/plugins/fancybox-for-wordpress/fancybox/fancybox.css?ver=3.1.2' type='text/css' media='all' />
<script type='text/javascript' src='http://www.e-fashion-awards.com/wordpress/wp-includes/js/l10n.js?ver=20101110'></script>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js?ver=3.1.2'></script>
<script type='text/javascript' src='http://www.e-fashion-awards.com/wordpress/wp-content/plugins/fancybox-for-wordpress/fancybox/jquery.fancybox.js?ver=1.3.4'></script>
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://www.e-fashion-awards.com/wordpress/xmlrpc.php?rsd" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://www.e-fashion-awards.com/wordpress/wp-includes/wlwmanifest.xml" /> 
<link rel='index' title='E-Fashion Awards &#8211; Concours Jeunes Créateurs' href='http://www.e-fashion-awards.com/' />
<meta name="generator" content="WordPress 3.1.2" />

<!-- Start Of Script Generated By cforms v11.7.3 [Oliver Seidel | www.deliciousdays.com] -->
<link rel="stylesheet" type="text/css" href="http://www.e-fashion-awards.com/wordpress/wp-content/plugins/cforms/styling/cforms.css" />
<script type="text/javascript" src="http://www.e-fashion-awards.com/wordpress/wp-content/plugins/cforms/js/cforms.js"></script>
<!-- End Of Script Generated By cforms -->


<!-- Fancybox for WordPress v3.0.1 -->
<script type="text/javascript">
jQuery(function(){

jQuery.fn.getTitle = function() { // Copy the title of every IMG tag and add it to its parent A so that fancybox can show titles
    var arr = jQuery("a.fancybox");
    jQuery.each(arr, function() {
        var title = jQuery(this).children("img").attr("title");
        jQuery(this).attr('title',title);
    })
}

// Supported file extensions
var thumbnails = jQuery("a:has(img)").filter( function() { return /(jpe?g|png|gif|bmp)$/i.test(jQuery(this).attr('href')) });

thumbnails.addClass("fancybox").attr("rel","fancybox").getTitle();

jQuery("a.fancybox").fancybox({
    'cyclic': false,
    'autoScale': true,
    'padding': 1,
    'opacity': true,
    'speedIn': 500,
    'speedOut': 500,
    'changeSpeed': 300,
    'overlayShow': true,
    'overlayOpacity': "0.8",
    'overlayColor': "#000000",
    'titleShow': true,
    'titlePosition': 'inside',
    'enableEscapeButton': true,
    'showCloseButton': false,
    'showNavArrows': true,
    'hideOnOverlayClick': true,
    'hideOnContentClick': true,
    'width': 560,
    'height': 340,
    'transitionIn': "fade",
    'transitionOut': "fade",
    'centerOnScroll': true
});

So I really don't know where my error come from...

Any idea ?


I could't see your js, but this error look like you are calling the fancybox this way:

object.fancybox()

and the correct way is:

$(object).fancybox()
4

2 回答 2

1

try

if (thumbnails.length>0) thumbnails.fancybox(//...

or $(".fancybox") if thumbnails is not good enough for fancybox

since in fact i don't see any links to any image on homepage, it could be the reason

于 2013-02-08T12:09:55.040 回答
0

我看不到你的 js,但这个错误看起来像你这样调用fancybox

object.fancybox()

正确的方法是:

$(object).fancybox()
于 2013-02-08T12:06:31.853 回答