David Biga
David Biga

Reputation: 2801

Issue with javascript/jquery code in wordpress

Hey guys out of no where I got this issue that came up on a wordpress site, no idea why. So let me tell you the issues:

Uncaught TypeError: Cannot read property 'msie' of undefined jquery.rating.pack.js:17 from jquery.rating.pack.js:17

Uncaught TypeError: Object [object Object] has no method 'live' from jquery.colorbox-min.js:4

So I have 2 plugins that stopped working because of this. I don't know if there was an update of some sort or where to even begin.

If you could give me a hand I would appreciate it.

Let me know if you need anything!

EDIT:

prodjsoundlighting.com - link to site with issue.

Upvotes: 1

Views: 1400

Answers (2)

SiamKreative
SiamKreative

Reputation: 126

You should update to the latest version of Colorbox. Grab it here.

Old versions of Colorbox relied on .live(), which is a deprecated function (from 1.7+) and removed completely from jQuery 1.9+.

Upvotes: 2

Igor Jerosimić
Igor Jerosimić

Reputation: 13741

You have two jQuery scripts included on your website, you need to remove the one that is not from wordpress.

/wp-includes/js/jquery/jquery.js?ver=1.8.3

http://code.jquery.com/jquery-latest.min.js

What happens is all jQuery extensions (colorbox, rating pack) attach themselves on jquery object from first jquery script, then the second jquery script overwrites jquery object and you can't access any of the previously attached jquery extensions.

EDIT: To avoid "$ is not a function" errors you will need to either replace all $ to jQuery

$(document).ready(function(){

will become

jQuery(document).ready(function(){

OR whats usually used, encapsulate your code with anonymous function like this:

(function($) {
    // here goes your javascript code where you access jquery object will dollar sign
})(jQuery);

P.S. There is one quick fix you could use until you fix your code. Just use this in the same place where you had that other jquery call:

<script>var $ = jQuery;</script>

Upvotes: 2

Related Questions