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.
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.
Is there any reason you might need to use jQuery.noConflict()?
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.js
does: application/x-javascript
. Can you get those other requests to use application/x-javascript
?
how about try to download the files on their demo that works already.
files on their demo:
- jQuery
- sexyLightbox
- easing
use the files that is seen to work... maybe it will help you...
精彩评论