Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: Object [object Object] has no method "fancybox"

I have really strange problem with fancybox(2.x). I was using this script for ages but i hadn't experienced such problem before.

So, i have website: http://tinyurl.com/6mx7an8 and i've included every jquery/fancybox files as manual says but the JS console gives me the error

Uncaught TypeError: Object [object Object] has no method 'fancybox'

Have you any idea what am i doing wrong? Any help would be appreciated :)

like image 923
mbajur Avatar asked Jan 30 '12 21:01

mbajur


4 Answers

There are couple of issues in your website.

  1. You are including jQuery library 2 times one before and after including fancybox plugin js because of which the plugin which is added is cleared by second jQuery library inclusion.
  2. There is some other library which is overridding $, so your code is not working because $ is not an alias for jQuery anymore. You can use jQuery.noConflict() to avoid conflicts with other libraries on the page which use the same variable $.
like image 100
ShankarSangoli Avatar answered Nov 10 '22 16:11

ShankarSangoli


Looks like jQuery is included twice, once near the top of the head and once near the bottom.

like image 26
danwellman Avatar answered Nov 10 '22 15:11

danwellman


I had a similar problem. Somehow, jQuery was being loaded twice. Turns out while testing something, I added a drupal_add_js line to load jquery in a block, which was disabled, but Drupal still evaluated the PHP in the disabled block.

When I removed the drupal_add_js line from the block, jQuery loaded fine, once per page.

like image 2
Brad Fellows Avatar answered Nov 10 '22 16:11

Brad Fellows


I have a css unify php script on my website that added both jquery and jquery postmessage plugin into the same javascript file.

So it was giving me the error above.

I have loaded the jquery postmessage separately without unifying it and it stopped giving me the error.

like image 1
Alexandru Trandafir Catalin Avatar answered Nov 10 '22 16:11

Alexandru Trandafir Catalin