jQuery error: "$ is undefined"

I'm using a enhanced version of Lightbox called SexyLightbox. It uses jQuery as its framework. When I initialize it, I get this error on regular invervals when the Lightbox isn't running and an infinite amount of times when I attempt to show a picture:

Error: $ is undefined
Source File: http://bagelstreet.se/sexylightbox/sexylightbox.v2.3.jquery.min.js
Line: 12

The initialization script goes as this:


    <link rel="stylesheet" href="sexylightbox/sexylightbox.css" type="text/css" media="all" />

    <script type="text/javascript" src="sexylightbox/jquery.min.js"></script>
    <script type="text/javascript" src="sexylightbox/jquery.easing.1.3.js"></script>

    <script type="text/javascript" src="sexylightbox/sexylightbox.v2.3.jquery.min.js"></script>

    <script type="text/javascript">
        $(document).ready(function(){
          SexyLightbox.initialize({color:'black', dir: 'sexyimages'});
        });
    </script>

UPDATE So - I've replaced the library, I'm using the unpacked version of sexylightbox. FireBug points out the error on the jQuery.bind() function, specifally on the bolded line:


jQuery.bind = function(object, method){
  var args = Array.prototype.slice.call(arguments, 2);  
  return function() {
    var args2 = [this].concat(args, $.makeArray( arguments ));  
    return method.apply(object, args2);  
  };  
};  

jQuery version being used is 1.3.2.

Any thoughts on what might be happening?

Solved

Problem was a coding error on SexyLightbox author's code. Used $ on jQuery.bind() before $ is defined.

Upvotes: 3

Views: 14320

Answers (4)

Reigel Gallarde
Reigel Gallarde

Reputation: 65254

how about try to download the files on their demo that works already.

files on their demo:

use the files that is seen to work... maybe it will help you...

Upvotes: 0

MDCore
MDCore

Reputation: 18115

I think it might have something to do with Content-Type. It seems that jquery.min.js isn't responding with a content type but sexylightbox.v2.3.jquery.jsdoes: application/x-javascript. Can you get those other requests to use application/x-javascript ?

Upvotes: 0

CalebD
CalebD

Reputation: 5022

Something in sexylightbox.v2.3.jquery.min.js is causing $ to be set to undefined. If you set a break point before that file loads, $ is correctly an alias for jQuery. I would try loading a version of sexylightbox.v2.3 that hasn't been run through Packer. That way you can properly use Firebug to figure out what is going on.

Upvotes: 5

justkt
justkt

Reputation: 14766

Is there any reason you might need to use jQuery.noConflict()?

Upvotes: 0

Related Questions