Incompatibility in all VM versions when using own jQuery

Please post your issues and questions about One Page Checkout for Virtuemart 2 to this forum.

Incompatibility in all VM versions when using own jQuery

Postby admin » Tue Aug 06, 2013 7:51 pm

Incompatibility in all VM versions when using own jQuery above 1.7.x

If you are using your own jquery library that is included from your theme directly, it's strongly recommended to disable "load virtuemart jquery" within VM's configuration at the tab shopfront. If you load two versions of the jquery library, the one that was loaded the last will be used (usually the VM's) and this may break your bootstrap's scripts that usually run on jQuery 1.9.x

Once you run the latest jQuery you should note that some functions in the core VM's files are made for jQuery 1.6.x, especially the datepicker in shopper fields rendered from:
\administrator\components\com_virtuemart\helpers\config.php

search for this code:
Code: Select all
$document->addScriptDeclaration('
//<![CDATA[
         jQuery(document).ready( function($) {
         $(".datepicker").live( "focus", function() {
            $( this ).datepicker({
               changeMonth: true,
               changeYear: true,
               '.$yearRange.'
               dateFormat:"'.$jsDateFormat.'",
               altField: $(this).prev(),
               altFormat: "yy-mm-dd"
            });
         });
         $(".js-date-reset").click(function() {
            $(this).prev("input").val("'.JText::_('COM_VIRTUEMART_NEVER').'").prev("input").val("0");
         });
      });
//]]>
      ');


and update it to:
Code: Select all
$document->addScriptDeclaration('
//<![CDATA[
         jQuery(document).ready( function($) {
         $(".datepicker").on( "focus", function() {
            $( this ).datepicker({
               changeMonth: true,
               changeYear: true,
               '.$yearRange.'
               dateFormat:"'.$jsDateFormat.'",
               altField: $(this).prev(),
               altFormat: "yy-mm-dd"
            });
         });
         $(".js-date-reset").click(function() {
            $(this).prev("input").val("'.JText::_('COM_VIRTUEMART_NEVER').'").prev("input").val("0");
         });
      });
//]]>
      ');


The symptoms of this incompatiblity are
- OPC does not update shipping for logged in users (remains blank)
- you have a javascript error on your site that breaks other functionality that can lead to unexpected behavior (Object [object Object] has no method 'live' )

Pls note, that i haven't tested the code, but only followed a suggestion from here:
http://stackoverflow.com/questions/1452 ... ive-jquery

Best Regards,
Stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Return to One Page Checkout for Virtuemart 2