VirtueMart Forum

VirtueMart 2 + 3 => Virtuemart Development and bug reports => Topic started by: balai on August 25, 2015, 13:36:34 pm

Title: Add a loader icon when Virtuemart updates content
Post by: balai on August 25, 2015, 13:36:34 pm
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:
Code: [Select]
            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) {

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