VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Zegenrijk on June 25, 2024, 14:02:10 PM

Title: re-trigger script
Post by: Zegenrijk on June 25, 2024, 14:02:10 PM
Hello,

I'm using on the productdetails page the module Tabs & Accordions from Regularlabs. But after hitting a customfield these tabs are not on a row anymore,but below each other.

I asked Regularlabs, the answer: 
The VM options load the contents in via ajax/javascript.
You will need to re-trigger the Tabs & Accordions script after new content is added.
Ask VM support on how to do that.

You would need to trigger:

RegularLabs.TabsAccordions.init(null);



On this post there is a solution, but it's not working: https://forum.virtuemart.de/thread/4299-joomla-plugin-funktioniert-nicht-in-produktbeschreibung/

J5.1.1, VM4.2.10 11010

How to solve?

Regards Michel

Title: Re: re-trigger script
Post by: Jumbo! on June 25, 2024, 22:24:41 PM
It is pretty simple. Add the following Javascript to your template.

(function($) {
    $('body').on('updateVirtueMartProductDetail', function() {
        if (typeof RegularLabs !== 'undefined' && typeof RegularLabs.TabsAccordions !== 'undefined' && typeof RegularLabs.TabsAccordions.init === 'function') {
            RegularLabs.TabsAccordions.init(null);
        }
    })
})(jQuery);
Title: Re: re-trigger script
Post by: Zegenrijk on June 27, 2024, 14:03:52 PM
Hello Jumbo,

Thanks for the code, but where do i add it exactly. In the provided link suggested is to put it in the spacer-buy-area of de productdetails default.php but then it chrashes....

Regards Michel
Title: Re: re-trigger script
Post by: Jumbo! on June 27, 2024, 22:42:53 PM
You need to add it to your template's custom Javascript file. If you use the default Cassiopea template, add it to the - media/templates/site/cassiopeia/js/user.js file. Create the file if it does not exist on your site.

If you use a 3rd party template, contact your template developer.
Title: Re: re-trigger script
Post by: Zegenrijk on June 28, 2024, 09:24:16 AM
Thank you Jumbo, solved!

Note: using Gantry framework with the Hydrogen template, so you can add a script in the Page Settings and check: Before </body>
Title: Re: re-trigger script
Post by: Jumbo! on June 28, 2024, 11:56:08 AM
You are welcome.