Fancybox is not a function

107,312

Solution 1

I already had this type of errors because i was reloading jQuery after the plugin import, check you don't reimport jquery by mistake (sometimes included in a package like jQuery tools).

Solution 2

I just had this issue, it seem some versions of jQuery are not compatible with versions of FancyBox, for example Fancybox 1.3.4 is buggy with jQuery versions below 1.7 and doesn't work on version higher than 1.8.

Solution 3

Possible Solutions:

1) have you already loaded jQuery? If not, then load it before any $ commands start.

2) Check, probably you are loading jquery library (.js) several times during the page. Try to load only one.

3) In the end of file, you can execute this javascript command: $ = jQuery.noConflict(); and it might solve. If not, then anywhere use the word jQuery instead of $, and it will work too.

Solution 4

You need to load the extensions like easing.js and mousewheel.js BEFORE the main fancybox plugin. That solves the problem.

Solution 5

If "fancybox" as a function does not exist, it is likely that either the jQuery source or the plugin source are failing to load into your page. Make sure that the pathing, file names, and extension are all correct.

EDIT: Make sure that you link to jQuery Source before you link to any plugins. If a plugin is loaded into your HTML before jQuery is, the plugin fails.

Share:
107,312
macha
Author by

macha

Updated on November 26, 2020

Comments

  • macha
    macha over 3 years

    Hello I am using the jQuery plugin fancybox to display bing maps when somebody enters an address into a textbox and hits the submit button beside it. And a fancybox is loaded and a map for that address is displayed. This is working well with my application, but the problem is, it is only working well on one page and on the other one, when I load it, it is giving me an error saying fancybox is not a function. I get to see this error in the error console and in the firebug console. I am not sure what could the problem. The same code works in another page, but it doesn't on this one?

    $("<a href=\"#showmap\">Map</a>").fancybox is not a function
    

    I am pretty sure it is not re-usability issue. But when I test to see if fancybox's original files have been loaded, they are loaded with the dom, so it might not be actual problem. But I am unable to understand what else could the problem be.

    This is my code

    abbr: is just a text bit. I have different divs based on what the user selects. And each div would have its own controls, which would start with that text and are appended with their own definitions such as mapresults, decValLat, decValLon etc.

    ex: abbr>>east and then the ids would be eastmapresults, eastdecValLat, eastdecValLon etc.

    function showMapFancybox(abbr){
        var abbr;
        $('#'+abbr+'mapresults').hide(); 
        $('<a href="#showmap">Map</a>').fancybox({
            overlayShow: true,
            onClosed: function() {
                $('#'+abbr+'mapresults').show();
                map_latdec = $('#decValLat').attr('value');
                map_longdec = $('#decValLon').attr('value');
                map_latdeg = $('#degValLat').attr('value');
                map_longdeg = $('#degValLon').attr('value');
    
                $('#'+abbr+'decValLatsub').val(map_latdec);
                $('#'+abbr+'decValLonsub').val(map_longdec);
                $('#'+abbr+'degValLatsub').val(map_latdeg+'N');
                $('#'+abbr+'degValLonsub').val(map_longdeg+'W');
            }
        }).click();    
    };