News:

Looking for documentation? Take a look on our wiki

Main Menu

multi variant custom fields - call scripts after change option

Started by caesarsk, March 09, 2016, 12:04:24 PM

Previous topic - Next topic

caesarsk

Hi all,

i using custom fields and multi variants for my products (color and size). At the same time I use a few extensions, such as zoom and jquery UI accordition function.
Everything works as it should (no jquery conflict etc.), the problem occurs when I change product parameters (e.g. color). The image is correctly loaded, but the scripts is not (no zoom, no accorition).
When I refreshing this page is of course everything is fine.

How do I call these scripts when I changing CF??

please help me, thx.

GJC Web Design

Thanks to my JS guru Spyros at https://www.virtuemarttemplates.eu/ he fixed my same issue with moving the JS scripts of e.g. zoom to the bottom of the prod details template and call them there with the native VM JS call

e.g.  (your code will be different)

//zoom
$j = '
var show_img="window"
function Zoom() {
jQuery("#Img_zoom2").elevateZoom({
gallery:"gallery_02" ,
cursor: "pointer" ,
zoomWindowPosition: 1,
zoomWindowOffetx: 10,
zoomWindowHeight: 360,
zoomWindowWidth:360,
zoomWindowFadeIn: 500,
zoomWindowFadeOut: 500,
lensFadeIn: 500,
lensFadeOut: 500,
showLens:true,
zoomType:show_img,
containLensZoom :false,
easing : true,
galleryActiveClass: "zoomThumbActive active",
loadingIcon: "images/ajax-loader.gif"
});
jQuery("#Img_zoom2").bind("click", function(e) { 
  var ez =   jQuery("#Img_zoom2").data("elevateZoom");
  var currentimg = jQuery("#Img_zoom2");
  console.log(currentimg);
  console.log(ez);
// console.log(ez.getGalleryList());
jQuery.fancybox(ez.getGalleryList());
  return false;
});
jQuery("#carousel2").jcarousel({
scroll:1  
});
}

jQuery(document).ready(function() {
Zoom();
});

';
vmJsApi::addJScript('zoomy',$j);
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Studio 42

Hi,
Your problem is because zoom script is loaded on document ready.
BUt on ajax call, document is already read. So adding any script are not called by ajax.

So to load your script, each time, you have to add it in the productdetails directly, or modify/use the Virtuemart Callback dynupdate javascript.
I proposed to add a custom trigger for some months to solve this problem so you can use external files for eg., but VM dev do not understand it, then for now, it's do all yourself.

caesarsk

thx all for reply.
I understand why this is happening. Insert the whole functions to tmp for me is not an option (using 3 scripts).
I tried to edit a file customfield.php (sublayouts folder) and add scripts (<script></script>) into the call return $html; (I mean multi variant use case 'C'), but... nothing
I try to look at dynamic update.

If anyone will have any solution, I will be very grateful to him

thx again

GJC Web Design

Well... Patrick and I are describing the same solution .. so... IMHO that is the solution.. 
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation