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

Custom Javascript on product-variation pages not executing

Started by mediakrt, February 08, 2019, 10:13:44 AM

Previous topic - Next topic

mediakrt

Hello dear Virtuemart-Community

I use a custom javascript to make manipulations on the product page. The javascript is loaded in the footer of the template and is working as expected. I only have one problem. On product pages where i can select different product options by a select field. The script is not loading/working/executing after i select a variation and the variation-information is loaded into the site by AJAX and the url of the page changes.

How is it possible, that my custom js is also working on all product-variantions when i change the variation via select field.

Thank you so much for your help and best regards!
Pascal

Jörgen

Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

GJC Web Design

that and make sure the JS is reloaded/reattached within the div that is renewed by the ajax
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

You have the solution to use
jQuery('mycontainer').on('click','mybutton','function(){
//code to execute
});
mycontainer should be outside the main product container or the product container for eg.
In this case you never loose the binded click
and you can load the function in an external file and check if object exist to not load again the function...