News:

Looking for documentation? Take a look on our wiki

Main Menu

Add a loader icon when Virtuemart updates content

Started by balai, August 25, 2015, 13:36:34 PM

Previous topic - Next topic

balai

I can see that the Virtuemart.updateContent  function (dynupdate.js) could takes some time to update the product's page after a variant is selected.

Though the user is unaware of that and could continue selecting variants or interacting with the product which will have no effect until the 1st request is finished

I suggest adding a loader image until the ajax call returns results.
We can do that over the Virtuemart.containerSelector which is the place to load the results.

The code could be something like that:

        $.ajax({
            url: url,
            dataType: 'html',
            beforeSend: function(){
            //Set loader code
            },
            success: function(data) {
                //Unset loader code
                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();
                    //Virtuemart.updateCartListener();

if (Virtuemart.updateImageEventListeners) Virtuemart.updateImageEventListeners();
if (Virtuemart.updateChosenDropdownLayout) Virtuemart.updateChosenDropdownLayout();
}
Virtuemart.isUpdatingContent = false;
if (callback && typeof(callback) === "function") {
callback();
}
            }
        });