TypeError: 'undefined' is not a function (

2019-02-26 06:04发布

Working on a new version of my site but can't get fancy box to load properly:

http://www.taintmovie.com/storecartloom2/

I checked for duplicate calls to jquery, but did not see any.

2条回答
时光不老,我们不散
2楼-- · 2019-02-26 06:42

Digging a little bit more into the issue, is not the packed version of the fancybox.js file that is broken as previously suggested (I compared the file with the fancybox website and they matched.)

There are three things you have to fix in your website in order to get rid of the error and make fancybox to work properly:

1). Close your <head> tag (currently there is not </head> closing tag)

2). You said you checked for jQuery duplicates BUT you are loading this script:

<script type="text/javascript" id="cljs" src="https://taintmovie.cartloom.com/cart/cl?dr=1&ol=1"></script>

LINK HERE, which includes jQuery v1.4.2 so it's conflicting with v1.7.2 already loaded.

This is actually the reason of this error:

Error: TypeError: $(".fancybox").fancybox is not a function
Source File: http://www.taintmovie.com/storecartloom2/
Line: 40

... you may want to edit that file and strip out the jQuery part.

3). You are binding fancybox to the selector .fancybox like :

$(".fancybox").fancybox(); 

...however your html looks like:

<a class="fancybox.iframe" href="http://www.youtube.com/embed/bHEEdUQCNsM?autoplay=1"><img src="images/pantheonblack300.png"></a>

you actually need to set the class fancybox besides the fancybox.iframe class like:

<a class="fancybox fancybox.iframe" href="http://www.youtube.com/embed/bHEEdUQCNsM?autoplay=1"><img src="images/pantheonblack300.png"></a>

... otherwise it won't work.

查看更多
女痞
3楼-- · 2019-02-26 07:02

Messing about with firebug it looks like the packed version of the fancybox.js is broken. I changed the source in the developer console to the unpacked version and it ran properly.

查看更多
登录 后发表回答