Issue with javascript/jquery code in wordpress - javascript

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.

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>

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+.

Related

jQuery plugin getting overwritten by another implementation of jQuery

I'm working on a Chrome extension that injects some scripts into Gmail, like jQuery and qtip. It worked without any problem until I added the Chrome extension LinkedIn Sales Navigator, which (I checked) is using jQuery too.
After adding it, I get this error:
TypeError: $(...).qtip is not a function(…)
And console.log($.qtip) returns undefined, while before adding this extension it was returning the function.
My flow to inject these scripts is:
In the manifest's "content_scripts" section I'm adding content.js.
In content.js file I'm using document.createElement("script") for each script and append it to the page's <head>.
I don't know what the problem is but I think it's an overwrite issue with jQuery but I'm not sure why nor how to solve it.
Thanks ahead for any help !
So, thanks to the comments I found out jQuery.noConflict(); existed, and have been able to check the availability of the wanted function and act accordingly :
if(!$.qtip)
jQuery.noConflict();

Uncaught TypeError: jQuery(...).fancybox is not a function |fancybox used in wordpress

I have a wordpress website and I want to show my video using fancybox, so I tried wp plugin like "fancybox for wordpress" and "easy fancybox".
But both of them give me the error message "Uncaught TypeError: jQuery(...).fancybox is not a function".
I search for many questions on here and found this can be jquery conflict, but I cannot figure out where is it.
here is my site http://skyblueenglish.co.uk
Notice that I only have one of above plugins at one time.
as per my thinking and till i have checked, what happen is,
in word-press you have included fancybox jQuery and it will obviously installed when you have installed the plugin. Now what happen is ,while using some JS function or JS Class it is mandatory to include jQuery file before we use/include the third party JS.
I checked the "View Source" for your page.
<script src="http://skyblueenglish.co.uk/wp-content/themes/skybluetheme/js/jquery.min.js"></script>
and i found that above JavaScript file is included in the footer.
i just removed that line and put it before
<script type='text/javascript' src='http://skyblueenglish.co.uk/wp-content/plugins/fancybox-for-wordpress/fancybox/jquery.fancybox.js?ver=1.3.4'></script>
and the error is Gone.
so what you have to do is, you have to find your footer, find the included jquery.min.js . remove it from the footer and include it from header.
Let me know if you dont understand anywhere.
;( function( $ ) {
$(document).ready(function(){
$(".fancybox").fancybox({
//....
});
});
} )( jQuery );
I did so many experiments on same topic and also tried with many different way to solve according to wherever I found similar topics on internet but trust me nothing worked out for me and then finally I simply tried to see what exactly error says:
Uncaught TypeError: $(...).fancybox is not a function
and for which I simply removed a line which was saying if($.fn.fancybox!==null).
I am not strong enough to understand Javascript or Jquery thing being fresher so I just tried with simple logic and it worked for me lol.
This might not be the right solution but just thought to share my experience so maybe for someone it may work too.
It worked properly without loosing any function by removing below code
if($.fn.fancybox!==null)
{$("a[class^='fancyBox']").fancybox();
$("a[class^='fancybox-thumb']").fancybox(
{helpers:{title:{type:'outside'},thumbs:{width:50,height:50}}});}
Thank You!

Magento add to cart doesnt work

Hello i have a problem with my add to cart button in my magento theme. i have changed all theme, but it doesnt work, please any can help me? i see in the console the error:
Uncaught TypeError: Cannot read property 'submit' of undefined gabinete-ice-2x24w-magg.html:220
onclick
but too appear error in my prototype.js im put here the file prototype.js, and here the live link http://masluz.panamerik.net/gabinete-ice-2x24w-magg.html i hope can help me guys thanks!
PROTOTYPE.JS LINK:
http://masluz.panamerik.net/js/prototype/prototype.js
When i go to checkout page to place the order have error too with prototype.js whats happend with this?
You are callling two copies of jQuery, this will cause all sorts of issues with Magento.
<script type="text/javascript" src="http://masluz.panamerik.net/js/megamenu/jquery-1-7-2.js"></script>
<script type="text/javascript" src="http://masluz.panamerik.net/js/iwd/all/jquery-1.10.2.min.js"></script>
You are using multiple version of jquery (1.7.2, 1. 1.10.2 and lastly 1.3.2). Since the last loaded version is 1.3.2 it is very much outdated and will not support many functions.
Also, you are loading jquery.noconflict file before your last jquery include, hence the errors are most likely because of the conflict issues.
You can try removing all other version of jquery and load noconflict.js file at the end of all the scripts.

tooltip jquery method not working on IE

I am running my App on Internet Explorer. There seems to be some issue with JQuery method:
$('.tooltip-demo').tooltip({
selector: "a[rel=tooltip]"
})
for which, i get the following error on the javascript console:
Object doesn't support property or method tooltip
What can be the cause of this error? please help.
There's no standard tooltip() function in jQuery, it's provided by a plugin. Ensure that you're a. loading the plugin and b. loading it after jQuery by placing the <script> tag for the plugin after the one for jQuery.
It looks like you're using a tool tip plugin for jQuery, but it hasn't been loaded when you make the call.
If this code is being run when the page loads, you should put it into a $(document).ready() function, to ensure that all the supporting libraries are loaded before it runs. This should solve the problem.

jquery bug with firebug

I am using jQuery javascript framework and whenever i load pages with firebug it returns "$" as an anonymous() function in console. Is there a way to fix it?
Thanks in advance.
Looks like jQuery was not loaded when you tried to call it. Try calling the object using jQuery instead of $ to confirm jQuery was actually loaded. Also, are you using other libraries like Prototype as well because they might be interfering with the $ object!! If yes, try using jQuery.noConflict().
I don't know why it happens, but yes I see it often too. Something about firebug interferes with the binding of the jQuery function to $ under some circumstance.
You're probably aware it's just the firebug console that's bugging out ( $() in included scripts should be working as expected), but it's worth mentioning. Usually I have to reload the page, or even kill the tab.
I'd like to understand why it happens, but for now when it happens (assuming jquery really is loaded in the page) I found I can fix it in the console with:
$ = jQuery;

Categories

Resources