News:

Support the VirtueMart project and become a member

Main Menu

plugin not working correctly with VM...and the dynupdate or AJAX??

Started by ch1vph, May 28, 2018, 13:49:28 PM

Previous topic - Next topic

ch1vph

Hi there,

I recently had an issue with a 'zoom plugin' called CmsMart Zoom Image, and my template not working together...which my template provider has now fixed - and the zoom does show up.

But there now seems to be an issue with the plugin not working correctly with Virtuemart...and the dynupdate or AJAX??

*THE PROBLEM HAPPENS IN A PRODUCT DETAILS VIEW....WHEN SWITCHING BETWEEN NEIGHBOUR PRODUCTS....& WHEN SWITCHING BETWEEN COLOURS ON MY SWATCH*

I am thinking this 'dynupdate' is an issue because I had a separate problem (when using my 'breakdesign' 'custom fields for all' colour swatch) as this also needs ajax to refresh the page - just like the option to switch through neighbour products - i think

Anyway I had to add in this line of code Stockablecustomfields.setEvents();

in to:

components/com_virtuemart/assets/js/dynupdate.js

....for the swatch to refresh the page and change the colour...AND I THINK THAT THE ZOOM PLUGIN NEEDS SOMETHING SIMILAR, FOR IT TO WORK???


Regards!
Chris H.

VM 3.2.14
Joomla! 3.8.8
PHP version 5.6.36
T3 framework 2.7.0
Site: https://ri2k.london
Joomlart - Brickstore temp



Studio 42

Hi,
The problem is that many plugin do not load dynamical the javascript but in the head.
The solution is to include the javascript inside your plugin render and not set in in the header. Adding it in VIrtuemart dynupdate is a bad way, because it Virtuemart change the code, your javascript stop to work on update.
Virtuemart core use a very complex way to include the script, but with last jQuery releases you can now simply use.
<script>
jQuery(document).ready(function($) {
// YOURCODE HERE
});
</script>


You can check for eg here http://pro.st42.fr/en/demo/extra-product/extra-product-demo-related.html and change product, the script is always working even on ajax loading(try the product neightbors on top)
Note that it work with or wihout ajax and this since Jquery 1.7+ if i'm right and Joomla 3.8 use jquery 1.12+