Modal popups not working on Virtuemart child product pages

This forum is for general questions about extensions for Joomla! 3.x.

Moderators: pe7er, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
bloatyhead
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Sat Nov 20, 2021 8:29 pm

Modal popups not working on Virtuemart child product pages

Post by bloatyhead » Thu Oct 26, 2023 4:11 pm

Hi all, I hope someone can help.

I've created Virtuemart parent and child products using BreakDesigns 'Custom Fields For All' and 'Stockable Custom Fields' plugins. I have a few modal popups in the parent product description (anchor tags with class="modal_link") which are inherited by the child products (I've also tried setting descriptions for the child products too). When a child product is loaded on the page (after different options/buttons are selected on the parent product), the modal links open in the browser window instead of in popups. The modals work ok on the parent product page.

BreakDesigns have told me that any javascript related functionality needs to be instantiated after the page update.
The same that happens after the page load. They've told me the place I need to trigger any js function, but I don't understand js so I don't know how to get the modals to work. . The file is in components/com_virtuemart/assets/js/dynupdate.js

This is an extract from the file, with what should be the correct position shown for the js to be inserted:

Code: Select all

Virtuemart.updateContent = function(url, callback) {

        if(Virtuemart.isUpdatingContent) return false;
        Virtuemart.isUpdatingContent = true;
        urlSuf='tmpl=component&format=html&dynamic=1';
        var glue = '&';
        if(url.indexOf('&') == -1 && url.indexOf('?') == -1){
			glue = '?';
        }
        url += glue+urlSuf;
		$(this).vm2front("startVmLoading");
		$.ajax({
            url: url,
            dataType: 'html',
            success: function(data) {
				var title = $(data).filter('title').text();
				$('title').text(title);
				var el = $(data).find(Virtuemart.containerSelector);
				if (! el.length) el = $(data).filter(Virtuemart.containerSelector);
				if (el.length) {
					Virtuemart.container.html(el.html());

					Virtuemart.updateCartListener();
					Virtuemart.updateDynamicUpdateListeners();

					if (Virtuemart.updateImageEventListeners) Virtuemart.updateImageEventListeners();
					if (Virtuemart.updateChosenDropdownLayout) Virtuemart.updateChosenDropdownLayout();
					if (typeof vm2tabs === 'function') {
						vm2tabs($("#ui-tabs .tabs"));
					}
					//Virtuemart.product($("form.product"));

					if(Virtuemart.recalculate) {
						$("form.js-recalculate").each(function(){
							if ($(this).find(".product-fields").length && !$(this).find(".no-vm-bind").length) {
								var id= $(this).find('input[name="virtuemart_product_id[]"]').val();
								Virtuemart.setproducttype($(this),id);
							}
						});
					}
					/*********** INSERT JS HERE ***********/
				}
				Virtuemart.isUpdatingContent = false;
				if (callback && typeof(callback) === "function") {
					callback();
				}
				$(this).vm2front("stopVmLoading");
            },
           
			error: function(datas) {
				alert('Error updating page');
				Virtuemart.isUpdatingContent = false;
				$(this).vm2front("stopVmLoading");
			},
			statusCode: {
				404: function() {
					Virtuemart.isUpdatingContent = false;
					$(this).vm2front("stopVmLoading");
					alert( "page not found" );
				}
			}
        });
        Virtuemart.isUpdatingContent = false;
    }
Can anyone tell me how to call the js needed to make the modals work? Is this bootstrap-related?

Many thanks for your time! :)

Post Reply

Return to “Extensions for Joomla! 3.x”