VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: toad78 on December 17, 2012, 19:11:06 PM

Title: jQuery conflicts
Post by: toad78 on December 17, 2012, 19:11:06 PM
I'm running the 'Superfish' menu module which requires jQuery. I'm also running VM2.014, which also requires jQuery.

I've noticed some things that don't make sense, but maybe someone else can.

We have one template for the same site that does not have more than one jQuery conflict. The menu module shows the arrows for the main menu items that have submenus. Superfish's jQuery call is the only one running.

But on another template for the same site where Virtuemart is running, there are two instances of it. One from the menu module and the other from VirtueMart. So we disabled the 'Using the VirtueMart jQuery'. Unfortunately, this caused the 'Add to Cart' button to not function correctly. You can click the button, but nothing would be added to the cart when you view the cart page. So I re-eneabled it.

Obviously we can't run more than one jQuery and both the menu module and VM (2.2014) need to be functional.

How can we run the two without both jQuery's running?
Title: Re: jQuery conflicts
Post by: bytelord on December 17, 2012, 19:14:52 PM
Hello,

To load only one jquery instance, either vm or your template or your other components that loads jquery. Prefer jquery 1.7.x for vm2.
You could use also any free plugin that controls the jquery loading, like jquery easy: http://extensions.joomla.org/extensions/core-enhancements/performance/jquery-scripts/18327

btw, any live URL to test it also?

Use firebug to examine your site code and styling .. also for checking js conflicts ... http://forum.virtuemart.net/index.php?topic=102850.0

Javascript conflicts:
http://dev.virtuemart.net/projects/virtuemart/wiki/General_JS-Problems_with_templates_and_jQuery
http://dev.virtuemart.net/projects/virtuemart/wiki/JavascriptCSS_Template_Overrides_and_Avoiding_Conflicts_between_Libraries

Regards
Title: Re: jQuery conflicts
Post by: toad78 on December 17, 2012, 19:26:45 PM
The site is here (http://"http://www.valleypistachio.com/).
Title: Re: jQuery conflicts
Post by: bytelord on December 17, 2012, 19:31:52 PM
Hello,

I remember your site we have seen it again ... you are loading jquery twice ... probably from k2 or from the module: mod_jt_superfish_menu
http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js

Unload it :)

Regards
Title: Re: jQuery conflicts
Post by: toad78 on December 17, 2012, 19:34:53 PM
Yes, I have done that. And when I do that, the template that does not use VM causes the drop down arrows to disappear. Therefore, I obviously need jQuery to load on the template that does not run VM.
Title: Re: jQuery conflicts
Post by: bytelord on December 17, 2012, 19:38:48 PM
If you unload vm2 jquery is it working? But your should load the jquery.noConflict....

Regards
Title: Re: jQuery conflicts
Post by: toad78 on December 17, 2012, 19:44:50 PM
Done that, too and it causes the 'Add to Cart' button not to work in the 'Product Details' screen.
Title: Re: jQuery conflicts
Post by: bytelord on December 17, 2012, 19:46:53 PM
Hello,

Then could use jquery easy and load only one library with it ... jquery 1.7.x and jquery noConflict also...

Regards