patricksweeney
patricksweeney

Reputation: 4022

'$' of object [object Window] is not a function

Just discovered an issue with the sorting plugin used on our cart, was working fine yesterday, and no changes have been made to it. The site is located here. I realize there is a mess of javascript and jquery in the HEAD, and I am sure that is not helping matters. The error I'm getting is Property '$' of object [object Window] is not a function. Is there possibly a jQuery conflict going on here?

Upvotes: 1

Views: 4514

Answers (4)

Barkermn01
Barkermn01

Reputation: 6842

Rap any Javascript code in a closure,

(function($){
    // code goes here
})(jQuery);

This will then prevent any problems with jQuery and the use of the $ as what your doing is creating a function that takes in the $ as a name, this then forces every thing inside closure will use the function local copy of $

Upvotes: 2

Clark T.
Clark T.

Reputation: 1470

another contributing factor to your issue is your loading both jquery and jqueryui twice.

Upvotes: 0

LCIII
LCIII

Reputation: 3646

You can also change the jquery variable with the noConflict method.

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
 var J=$.noConflict();
 J(".class").hide(); //use J instead of $ now
</script>

That way you KNOW it's not a jquery conflict with the $ character

Upvotes: 0

patricksweeney
patricksweeney

Reputation: 4022

kiranvj vcsjones both had the right idea about what to tackle first. We have one of those badges on there that was trying to append a string when it was expected a number, hence the Nan error. Fixed that, but still getting the error. I haven't uploaded my changes as this site takes a while, but I did fix the NaN eror, but still have the original problem.

Upvotes: 0

Related Questions