14

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://salomonsuperpark.pl/ 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 :)

Koedlt
  • 4,286
  • 8
  • 15
  • 33
mbajur
  • 4,406
  • 5
  • 49
  • 79

6 Answers6

53

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 $.
ShankarSangoli
  • 69,612
  • 13
  • 93
  • 124
6

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

danwellman
  • 9,068
  • 8
  • 60
  • 88
2

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.

Brad Fellows
  • 171
  • 8
1

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.

0

I got it working with this code

<script type="text/javascript">
    (function( $ ) {   
        $(document).ready( function( ) {  
            $("a#fancyBoxLink").fancybox({
                'href'   : '#popupvid',
                'titleShow'  : false,
                'transitionIn'  : 'elastic',
                'transitionOut' : 'elastic'
            });

        });
    })(jQuery);      
</script>
Joseph N.
  • 2,437
  • 1
  • 25
  • 31
0

Jquery sub library may included in main library ,For example jquery.ui.sortable.js i have included in jquery-ui.js while downloading and i added again it was giving a error for me.

script type="text/javascript" src="vendor/js/jquery-ui.js">

script type="text/javascript" src="vendor/js/jquery.ui.sortable.js">

so verify sub library included or not

Vinayak Shedgeri
  • 2,222
  • 1
  • 21
  • 24