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
This should probably be handled by the VM javascript handler:
https://docs.virtuemart.net/tutorials/development/196-the-vm-javascript-handler.html (https://docs.virtuemart.net/tutorials/development/196-the-vm-javascript-handler.html)
Jörgen @ Kreativ Fotografi
that and make sure the JS is reloaded/reattached within the div that is renewed by the ajax
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...