News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Bugfix: Avoiding JQuery collisions

Started by SniperSister, February 28, 2012, 19:35:47 PM

Previous topic - Next topic

SniperSister

Hi,

there is a whole bunch of issues which is related to collisions of different jquery versions which are loaded simultaneously. To avoid at least some of those collisions, i changed the file /administrator/components/com_virtuemart/helpers/config.php in lines 793 and 813, so that the method vmJsApi::jQuery looks like this:

function jQuery() {
if ( JFactory::getApplication()->get('jquery')) return false; // <------- new line!!
if ( !VmConfig::get('jquery',true ) && JFactory::getApplication()->isSite()) return false;
static $jquery;
// If exist exit
if ($jquery) return;
$document = JFactory::getDocument();
if(VmConfig::get('google_jquery',true)){
$document->addScript('//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js');
$document->addScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js');
} else {
$document->addScript(JURI::root(true).'/components/com_virtuemart/assets/js/jquery.min.js');
$document->addScript(JURI::root(true).'/components/com_virtuemart/assets/js/jquery-ui.min.js');
}
$document->addScript(JURI::base().'components/com_virtuemart/assets/js/jquery.ui.autocomplete.html.js');
$document->addScript(JURI::base().'components/com_virtuemart/assets/js/jquery.noConflict.js');

//JHTML::script('jquery.min.js', '//ajax.googleapis.com/ajax/libs/jquery/1.6.1/', false);
/*$document = JFactory::getDocument();
$document->addScriptDeclaration('jQuery.noConflict();');*/

$jquery = true;
                JFactory::getApplication()->set('jquery',true); <------ new line!
return true;
}


As you can see, i added the check if ( JFactory::getApplication()->get('jquery')) return false; because quite a lot Joomla extensions (all kind of yootheme extensions, k2, seblod...) are setting this parameter when they are loading jquery for the first time. On top of that, i added the line JFactory::getApplication()->set('jquery',true); to add support for this best practice to Virtuemart.

Best regards
David

Milbo

great, thank you, I add it now, very nice. I thought all the time, we seem to miss some knowledge, even we are atm quite good connected with some joomla developers.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

HC

Hi Milbo

I'm not sure wether this jquery issue is the same as the one we are discussing here:
https://forum.virtuemart.net/index.php?topic=95979.msg326766#msg326766
If it is, can you say something about when the next update is published including the bugfix?

I tried to insert the corrected php code, but it didn't help my issue - the Add to cart-button will not update the basket, only if I reload the page, the basket is showing the product. http://ny.udviklingsvej.dk/webshop/online-kurser-og-uddannelser/testprodukt-detail
It would indeed be nice to see a published fix for this particular problem, which doesn't seems to have any solutions yet in this forum.

Thanks a million